/usr/ports/ports-mgmt/pkg/work/pkg-2.8.4/external/sqlite/shell.c:4886:38: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
4886 | if( (p->nLoaded % 8)==0 && ((aData - (const unsigned char*)0)&7)==0 ){
| ^ ~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
I think the safe approach here would be casting through uintptr_t, which will be large enough to hold a pointer, unsigned has safe wrapping behavior, and avoids a NULL subtraction (which happens to work but UB compiler warnings are never pretty):
if( (p->nLoaded % 8)==0 && ((uintptr_t)aData & 7u)==0 ){
or maybe do away with the mod and obtain safe signedness for the first subexpression:
if( (p->nLoaded & 7u)==0 && ((uintptr_t)aData & 7u)==0 ){
Alternatively, refresh the sqlite version pulled in by pkg.
Feel free to forward upstream if still present in their latest code (haven't checked which version sqlite pkg-2.8.4 would pull in and/or if the issue is present in their code still).
Edit: I checked https://github.com/sqlite/sqlite/blob/version-3.53.4/src/shell.c.in but see no such code.
I think the safe approach here would be casting through
uintptr_t, which will be large enough to hold a pointer, unsigned has safe wrapping behavior, and avoids a NULL subtraction (which happens to work but UB compiler warnings are never pretty):if( (p->nLoaded % 8)==0 && ((uintptr_t)aData & 7u)==0 ){or maybe do away with the mod and obtain safe signedness for the first subexpression:
if( (p->nLoaded & 7u)==0 && ((uintptr_t)aData & 7u)==0 ){Alternatively, refresh the sqlite version pulled in by pkg.
Feel free to forward upstream if still present in their latest code (haven't checked which version sqlite pkg-2.8.4 would pull in and/or if the issue is present in their code still).Edit: I checked https://github.com/sqlite/sqlite/blob/version-3.53.4/src/shell.c.in but see no such code.