Skip to content

Build failure on newer kernels (LLVM/Clang): implicit declaration of strncpy in linuwu_sense.c #244

Description

@mesflit

Description

Building the driver on newer Linux kernels (e.g., 7.2.0-cachyos compiled with Clang/LLVM) fails due to implicit declaration errors for strncpy.

Modern Clang toolchains fail the build when non-declared or deprecated string functions like strncpy are used in kernel code.

Error Output

src/linuwu_sense.c:3574:5: error: call to undeclared library function 'strncpy' with type 'char *(char *, const char *, __size_t)' [-Wimplicit-function-declaration]
 3574 |     strncpy(input, buf, len);
      |     ^
src/linuwu_sense.c:4076:5: error: call to undeclared library function 'strncpy' with type 'char *(char *, const char *, __size_t)' [-Wimplicit-function-declaration]
 4076 |     strncpy(input_buf, buf, len);
      |     ^

Environment

  • OS: CachyOS Linux
  • Kernel: 7.2.0-rc6-1-cachyos-rc (or any modern kernel compiled with LLVM/Clang)
  • Compiler: Clang / LLVM

Suggested Fix / Workaround

Replacing all occurrences of strncpy with strscpy in src/linuwu_sense.c resolves the build error completely:

sed -i 's/strncpy/strscpy/g' src/linuwu_sense.c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions