浏览代码

cfgutils(k): gcc 2.95 compile fixes

- variables must be declared at the beginning of a block
Andrei Pelinescu-Onciul 16 年之前
父节点
当前提交
90031b9224
共有 1 个文件被更改,包括 8 次插入6 次删除
  1. 8 6
      modules_k/cfgutils/cfgutils.c

+ 8 - 6
modules_k/cfgutils/cfgutils.c

@@ -488,11 +488,6 @@ error:
   */
 static int MD5File(char *dest, const char *file_name)
 {
-	if (!dest || !file_name) {
-		LM_ERR("invalid parameter value\n");
-		return -1;
-	}
-
 	MD5_CTX context;
 	FILE *input;
 	unsigned char buffer[32768];
@@ -500,6 +495,12 @@ static int MD5File(char *dest, const char *file_name)
 	unsigned int counter, size;
 	
 	struct stat stats;
+	
+	if (!dest || !file_name) {
+		LM_ERR("invalid parameter value\n");
+		return -1;
+	}
+
     if (stat(file_name, &stats) != 0) {
 		LM_ERR("could not stat file %s\n", file_name);
 		return -1;
@@ -588,12 +589,13 @@ static int get_prob(struct sip_msg *bar, char *foo1, char *foo2)
 
 static int rand_event(struct sip_msg *bar, char *foo1, char *foo2)
 {
+	double tmp;
 	/* most of the time this will be disabled completly. Tis will also fix the
 	 * problem with the corner cases if rand() returned zero or RAND_MAX */
 	if ((*probability) == 0) return -1;
 	if ((*probability) == 100) return 1;
 
-	double tmp = ((double) rand() / RAND_MAX);
+	tmp = ((double) rand() / RAND_MAX);
 	LM_DBG("generated random %f\n", tmp);
 	if (tmp < ((double) (*probability) / 100)) {
 		LM_DBG("return true\n");