Download raw body.
qsort(3) and comparing values via subtraction
On Sun, May 01, 2022 at 12:23:29PM +0200, Theo Buehler wrote: > On Sun, May 01, 2022 at 12:09:05PM +0200, Stefan Sperling wrote: > > Our qsort(3) manual page contains a warning regarding subtraction > > of values larger than int: > > > > size_t lena = strlen(*(const char **)a); > > size_t lenb = strlen(*(const char **)b); > > /* > > * Do not subtract the lengths. The difference between values > > * cannot be represented by an int. > > */ > > return lena < lenb ? -1 : lena > lenb; > > > > The patch below fixes our qsort comparison functions accordingly. > > > > ok? > > ok - I would leave out all the 'else ' as they don't add anything. Thanks! Committed without 'else if'.
qsort(3) and comparing values via subtraction