summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2014-06-18 08:45:14 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2014-06-18 08:45:14 (GMT)
commitf627b3f33bc16f7d5a3d4d56bc6d5c935fecb8d9 (patch)
treec38b2c7ab1b3dc1087797bef6fd2291450b85039
parent11bfb0def2e216eece4b680eeb91a671099a46e5 (diff)
downloadmonitoring-plugins-f627b3f.tar.gz
lib/parse_ini.c: Fix Clang warnings
-rw-r--r--lib/parse_ini.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index a5b3d30..b33ce08 100644
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
@@ -166,7 +166,7 @@ read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
166 c = fgetc(f); 166 c = fgetc(f);
167 /* Strip leading whitespace */ 167 /* Strip leading whitespace */
168 if (i == 0) 168 if (i == 0)
169 for (c; isspace(c); c = fgetc(f)) 169 for (; isspace(c); c = fgetc(f))
170 continue; 170 continue;
171 /* nope, read to the end of the line */ 171 /* nope, read to the end of the line */
172 if (c != stanza[i]) { 172 if (c != stanza[i]) {
@@ -178,7 +178,7 @@ read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
178 if (i == stanza_len) { 178 if (i == stanza_len) {
179 c = fgetc(f); 179 c = fgetc(f);
180 /* Strip trailing whitespace */ 180 /* Strip trailing whitespace */
181 for (c; isspace(c); c = fgetc(f)) 181 for (; isspace(c); c = fgetc(f))
182 continue; 182 continue;
183 if (c == ']') 183 if (c == ']')
184 stanzastate = RIGHTSTANZA; 184 stanzastate = RIGHTSTANZA;
@@ -193,7 +193,6 @@ read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
193 case NOSTANZA: 193 case NOSTANZA:
194 die(STATE_UNKNOWN, "%s\n", 194 die(STATE_UNKNOWN, "%s\n",
195 _("Config file error")); 195 _("Config file error"));
196 break;
197 /* we're in a stanza, but for a different plugin */ 196 /* we're in a stanza, but for a different plugin */
198 case WRONGSTANZA: 197 case WRONGSTANZA:
199 GOBBLE_TO(f, c, '\n'); 198 GOBBLE_TO(f, c, '\n');
@@ -226,7 +225,7 @@ add_option(FILE *f, np_arg_list **optlst)
226{ 225{
227 np_arg_list *opttmp = *optlst, *optnew; 226 np_arg_list *opttmp = *optlst, *optnew;
228 char *linebuf = NULL, *lineend = NULL, *optptr = NULL, *optend = NULL; 227 char *linebuf = NULL, *lineend = NULL, *optptr = NULL, *optend = NULL;
229 char *eqptr = NULL, *valptr = NULL, *spaceptr = NULL, *valend = NULL; 228 char *eqptr = NULL, *valptr = NULL, *valend = NULL;
230 short done_reading = 0, equals = 0, value = 0; 229 short done_reading = 0, equals = 0, value = 0;
231 size_t cfg_len = 0, read_sz = 8, linebuf_sz = 0, read_pos = 0; 230 size_t cfg_len = 0, read_sz = 8, linebuf_sz = 0, read_pos = 0;
232 size_t opt_len = 0, val_len = 0; 231 size_t opt_len = 0, val_len = 0;
@@ -240,7 +239,7 @@ add_option(FILE *f, np_arg_list **optlst)
240 if (linebuf == NULL) 239 if (linebuf == NULL)
241 die(STATE_UNKNOWN, _("malloc() failed!\n")); 240 die(STATE_UNKNOWN, _("malloc() failed!\n"));
242 } 241 }
243 if (fgets(&linebuf[read_pos], read_sz, f) == NULL) 242 if (fgets(&linebuf[read_pos], (int)read_sz, f) == NULL)
244 done_reading = 1; 243 done_reading = 1;
245 else { 244 else {
246 read_pos = strlen(linebuf); 245 read_pos = strlen(linebuf);
@@ -278,10 +277,10 @@ add_option(FILE *f, np_arg_list **optlst)
278 continue; 277 continue;
279 --valend; 278 --valend;
280 /* Finally trim off trailing spaces */ 279 /* Finally trim off trailing spaces */
281 for (valend; isspace(*valend); valend--) 280 for (; isspace(*valend); valend--)
282 continue; 281 continue;
283 /* calculate the length of "--foo" */ 282 /* calculate the length of "--foo" */
284 opt_len = 1 + optend - optptr; 283 opt_len = (size_t)(1 + optend - optptr);
285 /* 1-character params needs only one dash */ 284 /* 1-character params needs only one dash */
286 if (opt_len == 1) 285 if (opt_len == 1)
287 cfg_len = 1 + (opt_len); 286 cfg_len = 1 + (opt_len);
@@ -290,7 +289,7 @@ add_option(FILE *f, np_arg_list **optlst)
290 /* if valptr<lineend then we have to also allocate space for "=bar" */ 289 /* if valptr<lineend then we have to also allocate space for "=bar" */
291 if (valptr < lineend) { 290 if (valptr < lineend) {
292 equals = value = 1; 291 equals = value = 1;
293 val_len = 1 + valend - valptr; 292 val_len = (size_t)(1 + valend - valptr);
294 cfg_len += 1 + val_len; 293 cfg_len += 1 + val_len;
295 } 294 }
296 /* if valptr==valend then we have "=" but no "bar" */ 295 /* if valptr==valend then we have "=" but no "bar" */