Skip to content

Warning in 0.18.1: no previous prototype for 'nsec_to_clock_t' [-Wmissing-prototypes]  #2142

@hhoffstaette

Description

@hhoffstaette

Describe the bug

NOT a bug, just a warning I caught which might turn into a build error depending on how the compiler feels on a particular day or config:

/usr/bin/x86_64-pc-linux-gnu-gcc-14 -Wp,-MMD,/tmp/portage/dev-debug/scap-driver-0.18.1/work/libs-0.18.1_build/driver/src/.ppm_cputime.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -march=native -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector -fno-stack-clash-protection -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -fmin-function-alignment=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-dangling-pointer -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-stringop-overflow -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wextra -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -g -gz=zstd -DHAS_ACCESS_OK_2 -DHAS_CLASS_CREATE_1 -DHAS_DEVNODE_ARG1_CONST  -DMODULE  -DKBUILD_BASENAME='"ppm_cputime"' -DKBUILD_MODNAME='"scap"' -D__KBUILD_MODNAME=kmod_scap -c -o /tmp/portage/dev-debug/scap-driver-0.18.1/work/libs-0.18.1_build/driver/src/ppm_cputime.o /tmp/portage/dev-debug/scap-driver-0.18.1/work/libs-0.18.1_build/driver/src/ppm_cputime.c   ; ./tools/objtool/objtool --hacks=jump_label --hacks=noinstr --orc --static-call --uaccess   --module /tmp/portage/dev-debug/scap-driver-0.18.1/work/libs-0.18.1_build/driver/src/ppm_cputime.o
/tmp/portage/dev-debug/scap-driver-0.18.1/work/libs-0.18.1_build/driver/src/ppm_cputime.c:342:10: warning: no previous prototype for 'nsec_to_clock_t' [-Wmissing-prototypes]
  342 | uint64_t nsec_to_clock_t(uint64_t x) {
      |          ^~~~~~~~~~~~~~~

As far as I can see nsec_to_clock_t is only used in driver/main.c, so maybe it would be better to move it there and make it static. Alternatively conjure up a prototype in some common header. As it turns out it's in <linux/jiffies.h> already.

How to reproduce it

Should reproduce with any build using -Wmissing-prototypes.

Expected behaviour

No warnings.

Environment

  • OS:

Gentoo

  • Kernel:

Linux 6.11.6-rc

  • Installation method:

Build from source package (Gentoo ebuild).

Additional context

It seems I missed this in the previous release cycle - sorry!

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions