Skip to content

C99 code vs. gcc defaults? #1416

@joe-lawrence

Description

@joe-lawrence

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions