> Date: Mon, 16 Nov 2015 11:41:09 -0500 > From: Michael McConville <mm...@mykolab.com> > > Craig Rodrigues wrote: > > Recently, I imported imsg.c from OpenBSD to the > > FreeBSD base system's libopenbsd: > > > > https://svnweb.freebsd.org/changeset/base/290375 > > > > When compiling on FreeBSD, we get a compiler warning with clang: > > > > cc -O2 -pipe -I/opt2/branches/head2/lib/libopenbsd -std=gnu99 > > -fstack-protector-strong -Wsystem-headers -Wall -Wno-format-y2k -W > > -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes > > -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -Wno-empty-body > > -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare > > -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function > > -Wno-enum-conversion -Wno-unused-local-typedef -Qunused-arguments -c > > /opt2/branches/head2/lib/libopenbsd/imsg.c -o imsg.o > > /opt2/branches/head2/lib/libopenbsd/imsg.c:78:6: warning: comparison of > > integers of different signs: 'unsigned long' and 'int' [-Wsign-compare] > > >= getdtablesize()) { > > ^ ~~~~~~~~~~~~~~~ > > 1 warning generated. > > > > I can certainly patch the code with a cast on FreeBSD to get rid of > > the compiler warning. However, I was wondering if there is a good fix > > that we can share between OpenBSD and FreeBSD? > > Both OSs define getdtablesize() as sysconf(_SC_OPEN_MAX). sysconf(3) > returns a long, so it seems more correct to make getdtablesize(3) return > a long or ssize_t. The return value has to be signed because sysconf(3) > is specified by POSIX to return -1 and set errno on failure.
Changing an existing API like that would be really bad. The code in question looks weird; imsg_fd_overhead is initialized to 0, but never changed it seems.