[Bug 258508] misc/rump: fix build with clang 13

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 14 Sep 2021 21:36:34 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258508

            Bug ID: 258508
           Summary: misc/rump: fix build with clang 13
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: vanilla@FreeBSD.org
          Reporter: dim@FreeBSD.org
             Flags: maintainer-feedback?(vanilla@FreeBSD.org)
          Assignee: vanilla@FreeBSD.org

During an exp-run for llvm 13 (see bug 258209), it turned out that misc/rump
fails to build with clang 13:

#   compile  librump/nist_ctr_drbg.pico
/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/obj/tooldir/bin/x86_64--netbsd-clang
-O2 -O2 -pipe -Wno-address-of-packed-member -fstack-protector-strong
-fno-strict-aliasing -ffreestandin
g -fno-strict-aliasing -mno-red-zone -mno-mmx -mno-sse -mno-avx -msoft-float 
-std=gnu99     -Wno-sign-compare -Wno-pointer-sign  -Wall -Wstrict-prototypes
-Wmissing-prototypes -Wpointer-arith -W
no-sign-compare  -Wa,--fatal-warnings -Wreturn-type -Wswitch -Wshadow
-Wcast-qual -Wwrite-strings -Wextra -Wno-unused-parameter -Wno-varargs
-Wno-sign-compare -Werror -Wno-format-zero-length -Wno
-pointer-sign     -DRUMPUSER_CONFIG=yes
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/obj/tooldir/autoconf
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/obj/tooldir/compat/i
nclude
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/obj/dest.stage/usr/include
 -DCOMPAT_50 -DCOMPAT_60 -DCOMPAT_70 -nostdinc -imacros
/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b
914579/src/lib/librump/../../sys/rump/include/opt/opt_rumpkernel.h -imacros
/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/obj/tooldir/include/opt_buildrump.h
-I/wrkdirs/usr/ports/misc/ru
mp/work/buildrump.sh-b914579/src/lib/librump -I.
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../../common/include
-I/wrkdirs/usr/ports/misc/rump/work/b
uildrump.sh-b914579/src/lib/librump/../../sys/rump/include
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/include/opt
-I/wrkdirs/usr/ports/misc/rump/work/
buildrump.sh-b914579/src/lib/librump/../../sys/rump/../arch
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/..
-DRUMP_USE_CTOR -DRUMP_CURLWP=RUMP_CURLWP___
THREAD -DKTRACE -U__FreeBSD__
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/librump/rumpkern
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src
/lib/librump/../../sys/rump/../lib/libkern/arch/x86_64  -D_RUMPKERNEL
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../lib/libkern/../../../common/lib/li
bc/quad
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../lib/libkern/../../../common/lib/libc/string
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b91
4579/src/lib/librump/../../sys/rump/../lib/libkern/../../../common/lib/libc/arch/x86_64/string
-I/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../lib/libke
rn/../../../common/include  -c    -fPIC
/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../crypto/nist_ctr_drbg/nist_ctr_drbg.c
-o nist_ctr_drbg.pico
/wrkdirs/usr/ports/misc/rump/work/buildrump.sh-b914579/src/lib/librump/../../sys/rump/../crypto/nist_ctr_drbg/nist_ctr_drbg.c:156:32:
error: performing pointer subtraction with a null pointer has
 undefined behavior [-Werror,-Wnull-pointer-subtraction]
        intptr_t ip = (const char *)p - (const char *)0;
                                      ^ ~~~~~~~~~~~~~~~

This particular new clang 13 warning is indeed a bug and should be fixed, by
simply casting the pointer 'p' directly to intptr_t instead.

The other new clang 13 warning emitted quite a lot is
-Wunused-but-set-variable. As this occurs quite often, and is not very useful
to patch without involving upstream, I propose disabling the warning for now.

-- 
You are receiving this mail because:
You are the assignee for the bug.