Просмотр исходного кода

lib/parse_ini.c - Fix clang warnings

Clang is a bit more picky about loops and casting, this should resolve all compile warnings
Spenser Reinhardt 11 лет назад
Родитель
Сommit
3df224feae
1 измененных файлов с 7 добавлено и 8 удалено
  1. 7 8
      lib/parse_ini.c

+ 7 - 8
lib/parse_ini.c

@@ -181,7 +181,7 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts){
 				for(i=0; i<stanza_len; i++){
 					c=fgetc(f);
 					/* Strip leading whitespace */
-					if(i==0) for(c; isspace(c); c=fgetc(f));
+					if(i==0) for(; isspace(c); c=fgetc(f));
 					/* nope, read to the end of the line */
 					if(c!=stanza[i]) {
 						GOBBLE_TO(f, c, '\n');
@@ -192,7 +192,7 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts){
 				if(i==stanza_len){
 					c=fgetc(f);
 					/* Strip trailing whitespace */
-					for(c; isspace(c); c=fgetc(f));
+					for(; isspace(c); c=fgetc(f));
 					if(c==']') stanzastate=RIGHTSTANZA;
 				}
 				break;
@@ -204,7 +204,6 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts){
 					 */
 					case NOSTANZA:
 						die(STATE_UNKNOWN, "%s\n", _("Config file error"));
-						break;
 					/* we're in a stanza, but for a different plugin */
 					case WRONGSTANZA:
 						GOBBLE_TO(f, c, '\n');
@@ -234,7 +233,7 @@ static int read_defaults(FILE *f, const char *stanza, np_arg_list **opts){
 static int add_option(FILE *f, np_arg_list **optlst){
 	np_arg_list *opttmp=*optlst, *optnew;
 	char *linebuf=NULL, *lineend=NULL, *optptr=NULL, *optend=NULL;
-	char *eqptr=NULL, *valptr=NULL, *spaceptr=NULL, *valend=NULL;
+	char *eqptr=NULL, *valptr=NULL, *valend=NULL;
 	short done_reading=0, equals=0, value=0;
 	size_t cfg_len=0, read_sz=8, linebuf_sz=0, read_pos=0;
 	size_t opt_len=0, val_len=0;
@@ -247,7 +246,7 @@ static int add_option(FILE *f, np_arg_list **optlst){
 			linebuf=realloc(linebuf, linebuf_sz);
 			if(linebuf==NULL) die(STATE_UNKNOWN, _("malloc() failed!\n"));
 		}
-		if(fgets(&linebuf[read_pos], read_sz, f)==NULL) done_reading=1;
+		if(fgets(&linebuf[read_pos], (int)read_sz, f)==NULL) done_reading=1;
 		else {
 			read_pos=strlen(linebuf);
 			if(linebuf[read_pos-1]=='\n') {
@@ -276,9 +275,9 @@ static int add_option(FILE *f, np_arg_list **optlst){
 	for(valend=valptr; valend<lineend; valend++);
 	--valend;
 	/* Finally trim off trailing spaces */
-	for(valend; isspace(*valend); valend--);
+	for(; isspace(*valend); valend--);
 	/* calculate the length of "--foo" */
-	opt_len=1+optend-optptr;
+	opt_len=(size_t)(1+optend-optptr);
 	/* 1-character params needs only one dash */
 	if(opt_len==1)
 		cfg_len=1+(opt_len);
@@ -287,7 +286,7 @@ static int add_option(FILE *f, np_arg_list **optlst){
 	/* if valptr<lineend then we have to also allocate space for "=bar" */
 	if(valptr<lineend) {
 		equals=value=1;
-		val_len=1+valend-valptr;
+		val_len=(size_t)(1+valend-valptr);
 		cfg_len+=1+val_len;
 	}
 	/* if valptr==valend then we have "=" but no "bar" */