fix up callsites of config_read to check for >= 0
authorDenis Vlasenko <vda.linux@googlemail.com>
Wed, 16 Jul 2008 23:04:49 +0000 (23:04 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Wed, 16 Jul 2008 23:04:49 +0000 (23:04 -0000)
libbb/parse_config.c
miscutils/crond.c
networking/nameif.c
util-linux/mdev.c

index e63204b093a244d1c4758cfefa85ef988bf8169a..f07099285c1e68677b11e6281943f2a4e2e749f3 100644 (file)
@@ -19,7 +19,7 @@ Typical usage:
        // open file
        if (config_open(filename, &p)) {
                // parse line-by-line
-               while (*config_read(&p, t, 3, 0, delimiters, comment_char)) { // 0..3 tokens
+               while (*config_read(&p, t, 3, 0, delimiters, comment_char) >= 0) { // 0..3 tokens
                        // use tokens
                        bb_error_msg("TOKENS: [%s][%s][%s]", t[0], t[1], t[2]);
                }
@@ -77,7 +77,7 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, int ntokens, int mint
 //TODO: speed up xmalloc_fgetline by internally using fgets, not fgetc
                line = xmalloc_fgetline(parser->fp);
                if (!line)
-                       return line;
+                       return -1;
 
                parser->lineno++;
                // handle continuations. Tito's code stolen :)
index af37bb15bcc7151f999c91909e87bd5565013bb5..41f1517536372aede7eabe8c59031d1bfe4343e3 100644 (file)
@@ -468,7 +468,7 @@ static void SynchronizeFile(const char *fileName)
                file->cf_User = xstrdup(fileName);
                pline = &file->cf_LineBase;
 
-               while (--maxLines && (n=config_read(&parser, tokens, 6, 0, " \t", '#')) > 0) {
+               while (--maxLines && (n=config_read(&parser, tokens, 6, 0, " \t", '#')) >= 0) {
                        CronLine *line;
 
                        if (DebugOpt) {
index 506f4fa1cb7d76a7f45b9e4cb8515dbe85d03e6c..c5a715e36186d0207a6390c3aed9a226b99ce26c 100644 (file)
@@ -163,7 +163,7 @@ int nameif_main(int argc, char **argv)
                struct parser_t parser;
                if (config_open(&parser, fname)) {
                        char *tokens[2];
-                       while (config_read(&parser, tokens, 2, 2, " \t", '#'))
+                       while (config_read(&parser, tokens, 2, 2, " \t", '#') >= 0)
                                prepend_new_eth_table(&clist, tokens[0], tokens[1]);
                        config_close(&parser);
                }
index 8968e45f8e1c06032455beb6ef93017d99cb3f26..c04410c0ce032195cf65ee044eb5492387a5fa42 100644 (file)
@@ -101,7 +101,7 @@ static void make_device(char *path, int delete)
                if (!config_open(&parser, "/etc/mdev.conf"))
                        goto end_parse;
 
-               while (config_read(&parser, tokens, 4, 3, " \t", '#')) {
+               while (config_read(&parser, tokens, 4, 3, " \t", '#') >= 0) {
                        regmatch_t off[1+9*ENABLE_FEATURE_MDEV_RENAME_REGEXP];
                        char *val;