Skip to content
  • Ilya Maximets's avatar
    smap: Return default on failure in smap_get_int/ullong. · 01393f00
    Ilya Maximets authored
    
    
    Currently smap_get_int/ullong doesn't check any conversion errors.
    Most implementations of atoi/strtoull return 0 in case of failure.
    
    This leads to returning zero in case of wrongly set database values.
    For example, commands
    
    	ovs-vsctl set interface iface options:key=\"\"
    	ovs-vsctl set interface iface options:key=qwe123
    	ovs-vsctl set interface iface options:key=abc
    
    will have exactly same effect as
    
    	ovs-vsctl set interface iface options:key=0
    
    in case where 'key' is an integer option of the iface.
    Can be checked with 'other_config:emc-insert-inv-prob' or other
    integer 'options' and 'other_config's.
    
    0 could be not a default and not safe value for many options and
    it'll be better to return default value instead if any.
    
    Conversion functions from 'util' library used to provide proper
    error handling.
    
    Signed-off-by: default avatarIlya Maximets <i.maximets@samsung.com>
    Signed-off-by: default avatarBen Pfaff <blp@ovn.org>
    Tested-by: default avatarJan Scheurich <jan.scheurich@ericsson.com>
    Acked-by: default avatarJan Scheurich <jan.scheurich@ericsson.com>
    01393f00