Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147400295
D31292.id92908.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D31292.id92908.diff
View Options
Index: lib/libc/stdlib/Makefile.inc
===================================================================
--- lib/libc/stdlib/Makefile.inc
+++ lib/libc/stdlib/Makefile.inc
@@ -18,6 +18,8 @@
strtol.c strtold.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c
+CFLAGS.qsort.c+= -Wsign-compare
+
# Work around an issue on case-insensitive file systems.
# libc has both _Exit.c and _exit.s and they both yield
# _exit.o (case insensitively speaking).
Index: lib/libc/stdlib/qsort.c
===================================================================
--- lib/libc/stdlib/qsort.c
+++ lib/libc/stdlib/qsort.c
@@ -171,7 +171,12 @@
pn = (char *)a + n * es;
d1 = MIN(pa - (char *)a, pb - pa);
vecswap(a, pb - d1, d1);
- d1 = MIN(pd - pc, pn - pd - es);
+ /*
+ * Cast es to preserve signedness of right-hand side of MIN()
+ * expression, to avoid sign ambiguity in the implied comparison. es
+ * is safely within [0, SSIZE_MAX].
+ */
+ d1 = MIN(pd - pc, pn - pd - (ssize_t)es);
vecswap(pb, pn - d1, d1);
d1 = pb - pa;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 11, 4:25 PM (6 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29516766
Default Alt Text
D31292.id92908.diff (1 KB)
Attached To
Mode
D31292: libc qsort(3): Eliminate ambiguous sign comparison
Attached
Detach File
Event Timeline
Log In to Comment