Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C99 code vs. gcc defaults? #1416

Closed
joe-lawrence opened this issue Oct 10, 2024 · 2 comments · Fixed by #1417
Closed

C99 code vs. gcc defaults? #1416

joe-lawrence opened this issue Oct 10, 2024 · 2 comments · Fixed by #1417

Comments

@joe-lawrence
Copy link
Contributor

Internal CI testing on RHEL-7.9 popped up this build error for #1415:

gcc -MMD -MP -I../kmod/patch -Iinsn -Wall -Wsign-compare -Wconversion -Wno-sign-conversion -g -Werror   -c -o create-diff-object.o create-diff-object.c
create-diff-object.c: In function ‘kpatch_create_pfe_sections’:
create-diff-object.c:3831:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
    for (int i=0; i<16; i++) {
    ^
create-diff-object.c:3831:4: note: use option -std=c99 or -std=gnu99 to compile your code

Up to now, we haven't merged any C99-isms like this into the code base, but it seems that default gcc options in distros like Fedora and the Ubuntu? github Travis CI must be assuming C99, so I never saw this error until the internal CI ran on RHEL-7.

A few things we could do:

  • Add -std=gnu99 to kpatch-build Makefile
  • Add -std=gnu89 to kpatch-build/Makefile
  • Add -std=gnu89 test to .travis.yml to catch them earlier in the PR
@joe-lawrence
Copy link
Contributor Author

@jpoimboe : any preferences given the maturity of the code base?

@jpoimboe
Copy link
Member

I think we can add -std=gnu11 to kpatch-build/Makefile as that's what the kernel uses and we tend to follow kernel style.

joe-lawrence added a commit to joe-lawrence/kpatch that referenced this issue Oct 10, 2024
Add -std=gnu11 to CFLAGS for kpatch-build tooling.  This aligns with the
kernel building for which we try to follow and avoids confusion when
older tooling may default to earlier versions.

Closes: dynup#1416 ("C99 code vs. gcc defaults?")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
joe-lawrence added a commit to joe-lawrence/kpatch that referenced this issue Oct 10, 2024
Add -std=gnu11 to CFLAGS for kpatch-build tooling.  This aligns with the
kernel build and avoids confusion when older tooling may default to
earlier versions.

Closes: dynup#1416 ("C99 code vs. gcc defaults?")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
zhjwong pushed a commit to zhjwong/kpatch that referenced this issue Nov 5, 2024
Add -std=gnu11 to CFLAGS for kpatch-build tooling.  This aligns with the
kernel build and avoids confusion when older tooling may default to
earlier versions.

Closes: dynup#1416 ("C99 code vs. gcc defaults?")
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
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 a pull request may close this issue.

2 participants