Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0c01270 in mainline


Ignore:
Timestamp:
2020-07-05T21:00:33Z (5 weeks ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
0f75a63
Parents:
a81a950d
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-05-08 11:02:56)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2020-07-05 21:00:33)
Message:

libconf: Fix iterator behavior, fix config error notification

Location:
uspace/lib/conf
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/conf/include/conf/configuration.h

    ra81a950d r0c01270  
    6666typedef enum {
    6767        CONFIGURATION_EMISSING_ITEM = -1,
    68         CONFIGURATION_EINVAL_BOOL = -2
     68        CONFIGURATION_EINVAL_BOOL = -2,
     69        CONFIGURATION_ELIMIT = -3
    6970} config_error_t;
    7071
  • uspace/lib/conf/src/configuration.c

    ra81a950d r0c01270  
    4343                const char *string = ini_item_iterator_value(it);
    4444                const size_t lineno = ini_item_iterator_lineno(it);
    45                 has_error = has_error ||
    46                     config_item->parse(string, field_dst, parse, lineno);
     45                bool success = config_item->parse(string, field_dst, parse, lineno);
     46                has_error = has_error || !success;
    4747        }
    4848
     
    104104        }
    105105
    106         return has_error ? EOK : EINVAL;
     106        return has_error ? EINVAL : EOK;
    107107}
    108108
  • uspace/lib/conf/src/ini.c

    ra81a950d r0c01270  
    489489bool ini_item_iterator_valid(ini_item_iterator_t *iterator)
    490490{
    491         bool empty = (iterator->cur_item != NULL);
    492         bool looped = (iterator->cur_item == iterator->first_item);
    493         return empty || (looped && iterator->incremented);
     491        bool empty = (iterator->cur_item == NULL);
     492        bool maybe_looped = (iterator->cur_item == iterator->first_item);
     493        return !(empty || (maybe_looped && iterator->incremented));
    494494}
    495495
  • uspace/lib/conf/test/ini.c

    ra81a950d r0c01270  
    109109            (str_cmp(first, "value") == 0 && str_cmp(second, "value2") == 0) ||
    110110            (str_cmp(first, "value2") == 0 && str_cmp(second, "value") == 0));
     111
     112        ini_item_iterator_inc(&it);
     113        PCUT_ASSERT_FALSE(ini_item_iterator_valid(&it));
    111114}
    112115
Note: See TracChangeset for help on using the changeset viewer.