Skip to content

fix: include <strings.h> for strncasecmp - #11

Open
bonifaido wants to merge 1 commit into
mainfrom
fix/strncasecmp-include
Open

fix: include <strings.h> for strncasecmp#11
bonifaido wants to merge 1 commit into
mainfrom
fix/strncasecmp-include

Conversation

@bonifaido

Copy link
Copy Markdown
Member

Fixes #6.

gcc 15 promotes -Wimplicit-function-declaration to an error, so the two strncasecmp() calls in sigv4.c fail the build. Under -std=c99 (__STRICT_ANSI__) glibc's string.h does not pull in strings.h, where POSIX declares the function.

sigv4.c:277:9: error: implicit declaration of function 'strncasecmp'; did you mean 'strncmp'? [-Wimplicit-function-declaration]

Changes

  • sigv4.h: add #include <strings.h>, only inside the standard-headers branch. Kernel builds set SIGV4_SYSTEM_HEADER and take the other branch — strings.h does not exist there, and strncasecmp comes from linux/string.h.
  • sigv4.c: cast key.data (unsigned char *) to char * at both call sites, as aws_sigv4_strcmp() already does. Without this, declaring the function just trades the error for two new -Wpointer-sign warnings on the platforms that were already compiling.

Verification

Reproduced and fixed on Ubuntu 26.04 / gcc 15.2.0 (aarch64), matching the reporter's environment.

Hosted build, -Wall -Wextra -std=c99:

before after
strncasecmp implicit decl 1 error gone
other warnings in sigv4.c 7 7 (unchanged)

The 7 remaining are pre-existing -Wpointer-sign on aws_sigv4_string("literal") — string literals passed as const unsigned char *. Untouched here; separate cleanup.

make test100%: Checks: 6, Failures: 0, Errors: 0.

Kernel path, compiled through SIGV4_SYSTEM_HEADER="c_system_header.h" with the driver's flags plus -Werror=implicit-function-declaration:

CC [M]  sigv4.o          # clean
nm -u sigv4.o → U strncasecmp    # resolves to the kernel's own

gcc 15 promotes implicit function declarations to errors, so the two
strncasecmp() calls broke the build. Under -std=c99 glibc's string.h
does not pull in strings.h, where POSIX declares it.

Include it only in the standard-headers branch -- kernel builds go
through SIGV4_SYSTEM_HEADER and get strncasecmp from linux/string.h.
Cast the key to char * as aws_sigv4_strcmp() already does, so
declaring the function doesn't just trade the error for -Wpointer-sign.

Fixes #6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

implicit declaration of function ‘strncasecmp’ on gcc15

1 participant