OSDN Git Service

rework sysconf table to treat zero entries as invalid
authorRich Felker <dalias@aerifal.cx>
Mon, 19 May 2014 15:19:49 +0000 (11:19 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 19 May 2014 15:19:49 +0000 (11:19 -0400)
commitff78355bc11257744759b5005d330e4a7583a4e4
tree04e0b6ea729f6e6b7d50d2d09de73af9fd35066f
parent9ca4dae5d895cf816eb1815511aba77a90f6acd7
rework sysconf table to treat zero entries as invalid

based on patch by Timo Teräs. previously, the value zero was used as a
literal zero, meaning that all invalid sysconf "names", which should
result in sysconf returning -1, had to be explicitly listed. (in
addition, it was not possible for sysconf to set errno to EINVAL, as
there was no distinction between -1 as an error and -1 as a valid
result.)

now, the value 0 is used for invalid/undefined slots in the table and
a new switch table entry is used for returning literal zeros.

in addition, an off-by-one error in checking against the table size is
fixed.
src/conf/sysconf.c