Skip to content
Snippets Groups Projects
  1. Feb 15, 2025
  2. Feb 08, 2025
    • Nathan Chancellor's avatar
      kbuild: Move -Wenum-enum-conversion to W=2 · 8f6629c0
      Nathan Chancellor authored
      -Wenum-enum-conversion was strengthened in clang-19 to warn for C, which
      caused the kernel to move it to W=1 in commit 75b5ab13 ("kbuild:
      Move -Wenum-{compare-conditional,enum-conversion} into W=1") because
      there were numerous instances that would break builds with -Werror.
      Unfortunately, this is not a full solution, as more and more developers,
      subsystems, and distributors are building with W=1 as well, so they
      continue to see the numerous instances of this warning.
      
      Since the move to W=1, there have not been many new instances that have
      appeared through various build reports and the ones that have appeared
      seem to be following similar existing patterns, suggesting that most
      instances of this warning will not be real issues. The only alternatives
      for silencing this warning are adding casts (which is generally seen as
      an ugly practice) or refactoring the enums to macro defines or a unified
      enum (which may be undesirable because of type safety in other parts of
      the code).
      
      Move the warning to W=2, where warnings that occur frequently but may be
      relevant should reside.
      
      Cc: stable@vger.kernel.org
      Fixes: 75b5ab13 ("kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1")
      Link: https://lore.kernel.org/ZwRA9SOcOjjLJcpi@google.com/
      
      
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8f6629c0
  3. Feb 07, 2025
  4. Feb 06, 2025
  5. Feb 05, 2025
  6. Feb 01, 2025
  7. Jan 31, 2025
  8. Jan 30, 2025
    • Kees Cook's avatar
      kbuild: Use -fzero-init-padding-bits=all · dce4aab8
      Kees Cook authored
      
      GCC 15 introduces a regression in "= { 0 }" style initialization of
      unions that Linux has depended on for eliminating uninitialized variable
      contents. GCC does not seem likely to fix it[1], instead suggesting[2]
      that affected projects start using -fzero-init-padding-bits=unions.
      
      To avoid future surprises beyond just the current situation with unions,
      enable -fzero-init-padding-bits=all when available (GCC 15+). This will
      correctly zero padding bits in unions and structs that might have been
      left uninitialized, and will make sure there is no immediate regression
      in union initializations. As seen in the stackinit KUnit selftest union
      cases, which were passing before, were failing under GCC 15:
      
          not ok 18 test_small_start_old_zero
          ok 29 test_small_start_dynamic_partial # SKIP XFAIL uninit bytes: 63
          ok 32 test_small_start_assigned_dynamic_partial # SKIP XFAIL uninit bytes: 63
          ok 67 test_small_start_static_partial # SKIP XFAIL uninit bytes: 63
          ok 70 test_small_start_static_all # SKIP XFAIL uninit bytes: 56
          ok 73 test_small_start_dynamic_all # SKIP XFAIL uninit bytes: 56
          ok 82 test_small_start_assigned_static_partial # SKIP XFAIL uninit bytes: 63
          ok 85 test_small_start_assigned_static_all # SKIP XFAIL uninit bytes: 56
          ok 88 test_small_start_assigned_dynamic_all # SKIP XFAIL uninit bytes: 56
      
      The above all now pass again with -fzero-init-padding-bits=all added.
      
      This also fixes the following cases for struct initialization that had
      been XFAIL until now because there was no compiler support beyond the
      larger "-ftrivial-auto-var-init=zero" option:
      
          ok 38 test_small_hole_static_all # SKIP XFAIL uninit bytes: 3
          ok 39 test_big_hole_static_all # SKIP XFAIL uninit bytes: 124
          ok 40 test_trailing_hole_static_all # SKIP XFAIL uninit bytes: 7
          ok 42 test_small_hole_dynamic_all # SKIP XFAIL uninit bytes: 3
          ok 43 test_big_hole_dynamic_all # SKIP XFAIL uninit bytes: 124
          ok 44 test_trailing_hole_dynamic_all # SKIP XFAIL uninit bytes: 7
          ok 58 test_small_hole_assigned_static_all # SKIP XFAIL uninit bytes: 3
          ok 59 test_big_hole_assigned_static_all # SKIP XFAIL uninit bytes: 124
          ok 60 test_trailing_hole_assigned_static_all # SKIP XFAIL uninit bytes: 7
          ok 62 test_small_hole_assigned_dynamic_all # SKIP XFAIL uninit bytes: 3
          ok 63 test_big_hole_assigned_dynamic_all # SKIP XFAIL uninit bytes: 124
          ok 64 test_trailing_hole_assigned_dynamic_all # SKIP XFAIL uninit bytes: 7
      
      All of the above now pass when built under GCC 15. Tests can be seen
      with:
      
          ./tools/testing/kunit/kunit.py run stackinit --arch=x86_64 \
              --make_option CC=gcc-15
      
      Clang continues to fully initialize these kinds of variables[3] without
      additional flags.
      
      Suggested-by: default avatarJakub Jelinek <jakub@redhat.com>
      Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118403 [1]
      Link: https://lore.kernel.org/linux-toolchains/Z0hRrrNU3Q+ro2T7@tucnak/ [2]
      Link: https://github.com/llvm/llvm-project/commit/7a086e1b2dc05f54afae3591614feede727601fa
      
       [3]
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      Acked-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Link: https://lore.kernel.org/r/20250127191031.245214-3-kees@kernel.org
      
      
      Signed-off-by: default avatarKees Cook <kees@kernel.org>
      dce4aab8
    • Yunhui Cui's avatar
      riscv: add a warning when physical memory address overflows · 10197129
      Yunhui Cui authored
      
      The part of physical memory that exceeds the size of the linear mapping
      will be discarded. When the system starts up normally, a warning message
      will be printed to prevent confusion caused by the mismatch between the
      system memory and the actual physical memory.
      
      Signed-off-by: default avatarYunhui Cui <cuiyunhui@bytedance.com>
      Reviewed-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
      Tested-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
      Link: https://lore.kernel.org/r/20240814062625.19794-1-cuiyunhui@bytedance.com
      
      
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      10197129
  9. Jan 29, 2025
    • Masahiro Yamada's avatar
      kconfig: fix memory leak in sym_warn_unmet_dep() · a409fc14
      Masahiro Yamada authored
      
      The string allocated in sym_warn_unmet_dep() is never freed, leading
      to a memory leak when an unmet dependency is detected.
      
      Fixes: f8f69dc0 ("kconfig: make unmet dependency warnings readable")
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarPetr Vorel <pvorel@suse.cz>
      a409fc14
    • Masahiro Yamada's avatar
      kconfig: fix file name in warnings when loading KCONFIG_DEFCONFIG_LIST · a314f52a
      Masahiro Yamada authored
      
      Most 'make *config' commands use .config as the base configuration file.
      
      When .config does not exist, Kconfig tries to load a file listed in
      KCONFIG_DEFCONFIG_LIST instead.
      
      However, since commit b75b0a81 ("kconfig: change defconfig_list
      option to environment variable"), warning messages have displayed an
      incorrect file name in such cases.
      
      Below is a demonstration using Debian Trixie. While loading
      /boot/config-6.12.9-amd64, the warning messages incorrectly show .config
      as the file name.
      
      With this commit, the correct file name is displayed in warnings.
      
      [Before]
      
        $ rm -f .config
        $ make config
        #
        # using defaults found in /boot/config-6.12.9-amd64
        #
        .config:6804:warning: symbol value 'm' invalid for FB_BACKLIGHT
        .config:9895:warning: symbol value 'm' invalid for ANDROID_BINDER_IPC
      
      [After]
      
        $ rm -f .config
        $ make config
        #
        # using defaults found in /boot/config-6.12.9-amd64
        #
        /boot/config-6.12.9-amd64:6804:warning: symbol value 'm' invalid for FB_BACKLIGHT
        /boot/config-6.12.9-amd64:9895:warning: symbol value 'm' invalid for ANDROID_BINDER_IPC
      
      Fixes: b75b0a81 ("kconfig: change defconfig_list option to environment variable")
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      a314f52a
  10. Jan 26, 2025
    • Masahiro Yamada's avatar
      genksyms: fix syntax error for attribute before init-declarator · a23d4c2f
      Masahiro Yamada authored
      
      A longstanding issue with genksyms is that it has hidden syntax errors.
      
      For example, genksyms fails to parse the following valid code:
      
          int x, __attribute__((__section__(".init.data")))y;
      
      Here, only 'y' is annotated by the attribute, although I am not aware
      of actual uses of this pattern in the kernel tree.
      
      When a syntax error occurs, yyerror() is called. However,
      error_with_pos() is a no-op unless the -w option is provided.
      
      You can observe syntax errors by manually passing the -w option.
      
          $ echo 'int x, __attribute__((__section__(".init.data")))y;' | scripts/genksyms/genksyms -w
          <stdin>:1: syntax error
      
      This commit allows attributes to be placed between a comma and
      init_declarator.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      a23d4c2f
    • Masahiro Yamada's avatar
      genksyms: fix syntax error for builtin (u)int*x*_t types · c8258405
      Masahiro Yamada authored
      
      A longstanding issue with genksyms is that it has hidden syntax errors.
      
      When a syntax error occurs, yyerror() is called. However,
      error_with_pos() is a no-op unless the -w option is provided.
      
      You can observe syntax errors by manually passing the -w option.
      
      For example, genksyms fails to parse the following code in
      arch/arm64/lib/xor-neon.c:
      
          static inline uint64x2_t eor3(uint64x2_t p, uint64x2_t q, uint64x2_t r)
          {
                  [ snip ]
          }
      
      The syntax error occurs because genksyms does not recognize the
      uint64x2_t keyword.
      
      This commit adds support for builtin types described in Arm Neon
      Intrinsics Reference.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      c8258405
    • Masahiro Yamada's avatar
      genksyms: fix syntax error for attribute after 'union' · 6494bd2d
      Masahiro Yamada authored
      
      A longstanding issue with genksyms is that it has hidden syntax errors.
      
      When a syntax error occurs, yyerror() is called. However,
      error_with_pos() is a no-op unless the -w option is provided.
      
      You can observe syntax errors by manually passing the -w option.
      
      For example, with CONFIG_MODVERSIONS=y on v6.13-rc1:
      
          $ make -s KCFLAGS=-D__GENKSYMS__ fs/lockd/svc.i
          $ cat fs/lockd/svc.i | scripts/genksyms/genksyms -w
              [ snip ]
          ./include/net/addrconf.h:35: syntax error
      
      The syntax error occurs in the following code in include/net/addrconf.h:
      
          union __packed {
                  [ snip ]
          };
      
      The issue arises from __packed, which is defined as
      __attribute__((__packed__)), immediately after the 'union' keyword.
      
      This commit allows the 'union' keyword to be followed by attributes.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      6494bd2d
  11. Jan 25, 2025
  12. Jan 18, 2025
    • Masahiro Yamada's avatar
      genksyms: fix syntax error for attribute after 'struct' · 82db1c29
      Masahiro Yamada authored
      
      A longstanding issue with genksyms is that it has hidden syntax errors.
      
      When a syntax error occurs, yyerror() is called. However,
      error_with_pos() is a no-op unless the -w option is provided.
      
      You can observe syntax errors by manually passing the -w option.
      
      For example, with CONFIG_MODVERSIONS=y on v6.13-rc1:
      
          $ make -s KCFLAGS=-D__GENKSYMS__ arch/x86/kernel/cpu/mshyperv.i
          $ cat arch/x86/kernel/cpu/mshyperv.i | scripts/genksyms/genksyms -w
              [ snip ]
          ./arch/x86/include/asm/svm.h:122: syntax error
      
      The syntax error occurs in the following code in arch/x86/include/asm/svm.h:
      
          struct __attribute__ ((__packed__)) vmcb_control_area {
                  [ snip ]
          };
      
      The issue arises from __attribute__ immediately after the 'struct'
      keyword.
      
      This commit allows the 'struct' keyword to be followed by attributes.
      
      The lexer must be adjusted because dont_want_brace_phase should not be
      decremented while processing attributes.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      82db1c29
    • Masahiro Yamada's avatar
      genksyms: fix syntax error for attribute after abstact_declarator · 2ac068cb
      Masahiro Yamada authored
      
      A longstanding issue with genksyms is that it has hidden syntax errors.
      
      When a syntax error occurs, yyerror() is called. However,
      error_with_pos() is a no-op unless the -w option is provided.
      
      You can observe syntax errors by manually passing the -w option.
      
      For example, with CONFIG_MODVERSIONS=y on v6.13-rc1:
      
          $ make -s KCFLAGS=-D__GENKSYMS__ kernel/module/main.i
          $ cat kernel/module/main.i | scripts/genksyms/genksyms -w
              [ snip ]
          kernel/module/main.c:97: syntax error
      
      The syntax error occurs in the following code in kernel/module/main.c:
      
          static void __mod_update_bounds(enum mod_mem_type type __maybe_unused, void *base,
                                          unsigned int size, struct mod_tree_root *tree)
          {
                  [ snip ]
          }
      
      The issue arises from __maybe_unused, which is defined as
      __attribute__((__unused__)).
      
      This commit allows direct_abstract_declarator to be followed with
      attributes.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      2ac068cb
    • Masahiro Yamada's avatar
      genksyms: fix syntax error for attribute before nested_declarator · a8b7d066
      Masahiro Yamada authored
      
      A longstanding issue with genksyms is that it has hidden syntax errors.
      
      When a syntax error occurs, yyerror() is called. However,
      error_with_pos() is a no-op unless the -w option is provided.
      
      You can observe syntax errors by manually passing the -w option.
      
      For example, with CONFIG_MODVERSIONS=y on v6.13-rc1:
      
          $ make -s KCFLAGS=-D__GENKSYMS__ drivers/acpi/prmt.i
          $ cat drivers/acpi/prmt.i | scripts/genksyms/genksyms -w
              [ snip ]
          drivers/acpi/prmt.c:56: syntax error
      
      The syntax error occurs in the following code in drivers/acpi/prmt.c:
      
          struct prm_handler_info {
                  [ snip ]
                  efi_status_t (__efiapi *handler_addr)(u64, void *);
                  [ snip ]
          };
      
      The issue arises from __efiapi, which is defined as either
      __attribute__((ms_abi)) or __attribute__((regparm(0))).
      
      This commit allows nested_declarator to be prefixed with attributes.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      a8b7d066
    • Masahiro Yamada's avatar
      genksyms: fix syntax error for attribute before abstract_declarator · 2966b66c
      Masahiro Yamada authored
      
      A longstanding issue with genksyms is that it has hidden syntax errors.
      
      When a syntax error occurs, yyerror() is called. However,
      error_with_pos() is a no-op unless the -w option is provided.
      
      You can observe syntax errors by manually passing the -w option.
      
      For example, with CONFIG_MODVERSIONS=y on v6.13-rc1:
      
          $ make -s KCFLAGS=-D__GENKSYMS__ init/main.i
          $ cat init/main.i | scripts/genksyms/genksyms -w
              [ snip ]
          ./include/linux/efi.h:1225: syntax error
      
      The syntax error occurs in the following code in include/linux/efi.h:
      
          efi_status_t
          efi_call_acpi_prm_handler(efi_status_t (__efiapi *handler_addr)(u64, void *),
                                    u64 param_buffer_addr, void *context);
      
      The issue arises from __efiapi, which is defined as either
      __attribute__((ms_abi)) or __attribute__((regparm(0))).
      
      This commit allows abstract_declarator to be prefixed with attributes.
      
      To avoid conflicts, I tweaked the rule for decl_specifier_seq. Due to
      this change, a standalone attribute cannot become decl_specifier_seq.
      Otherwise, I do not know how to resolve the conflicts.
      
      The following code, which was previously accepted by genksyms, will now
      result in a syntax error:
      
          void my_func(__attribute__((unused))x);
      
      I do not think it is a big deal because GCC also fails to parse it.
      
          $ echo 'void my_func(__attribute__((unused))x);' | gcc -c -x c -
          <stdin>:1:37: error: unknown type name 'x'
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      2966b66c
    • Masahiro Yamada's avatar
      genksyms: decouple ATTRIBUTE_PHRASE from type-qualifier · ec28bfff
      Masahiro Yamada authored
      
      The __attribute__ keyword can appear in more contexts than 'const' or
      'volatile'.
      
      To avoid grammatical conflicts with future changes, ATTRIBUTE_PHRASE
      should not be reduced into type_qualifier.
      
      No functional changes are intended.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      ec28bfff
    • Masahiro Yamada's avatar
      genksyms: record attributes consistently for init-declarator · ccc11a19
      Masahiro Yamada authored
      
      I believe the missing action here is a bug.
      
      For rules with no explicit action, the following default is used:
      
          { $$ = $1; }
      
      However, in this case, $1 is the value of attribute_opt itself. As a
      result, the value of attribute_opt is always NULL.
      
      The following test code demonstrates inconsistent behavior.
      
          int x __attribute__((__aligned__(4)));
          int y __attribute__((__aligned__(4))) = 0;
      
      The attribute is recorded only when followed by an initializer.
      
      This commit adds the correct action to propagate the value of the
      ATTRIBUTE_PHRASE token.
      
      With this change, the attribute in the example above is consistently
      recorded for both 'x' and 'y'.
      
      [Before]
      
          $ cat <<EOF | scripts/genksyms/genksyms -d
          int x __attribute__((__aligned__(4)));
          int y __attribute__((__aligned__(4))) = 0;
          EOF
          Defn for type0 x == <int x >
          Defn for type0 y == <int y __attribute__ ( ( __aligned__ ( 4 ) ) ) >
          Hash table occupancy 2/4096 = 0.000488281
      
      [After]
      
          $ cat <<EOF | scripts/genksyms/genksyms -d
          int x __attribute__((__aligned__(4)));
          int y __attribute__((__aligned__(4))) = 0;
          EOF
          Defn for type0 x == <int x __attribute__ ( ( __aligned__ ( 4 ) ) ) >
          Defn for type0 y == <int y __attribute__ ( ( __aligned__ ( 4 ) ) ) >
          Hash table occupancy 2/4096 = 0.000488281
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      ccc11a19
    • Masahiro Yamada's avatar
      genksyms: restrict direct-declarator to take one parameter-type-list · aa710cee
      Masahiro Yamada authored
      
      Similar to the previous commit, this change makes the parser logic a
      little more accurate.
      
      Currently, genksyms accepts the following invalid code:
      
          struct foo {
                  int (*callback)(int)(int)(int);
          };
      
      A direct-declarator should not recursively absorb multiple
      ( parameter-type-list ) constructs.
      
      In the example above, (*callback) should be followed by at most one
      (int).
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      aa710cee
    • Masahiro Yamada's avatar
      genksyms: restrict direct-abstract-declarator to take one parameter-type-list · c2f1846b
      Masahiro Yamada authored
      While there is no more grammatical ambiguity in genksyms, the parser
      logic is still inaccurate.
      
      For example, genksyms accepts the following invalid C code:
      
          void my_func(int ()(int));
      
      This should result in a syntax error because () cannot be reduced to
      <direct-abstract-declarator>.
      
      ( <abstract-declarator> ) can be reduced, but <abstract-declarator>
      must not be empty in the following grammar from K&R [1]:
      
        <direct-abstract-declarator> ::=  ( <abstract-declarator> )
                                       | {<direct-abstract-declarator>}? [ {<constant-expression>}? ]
                                       | {<direct-abstract-declarator>}? ( {<parameter-type-list>}? )
      
      Furthermore, genksyms accepts the following weird code:
      
          void my_func(int (*callback)(int)(int)(int));
      
      The parser allows <direct-abstract-declarator> to recursively absorb
      multiple ( {<parameter-type-list>}? ), but this behavior is incorrect.
      
      In the example above, (*callback) should be followed by at most one
      (int).
      
      [1]: https://cs.wmich.edu/~gupta/teaching/cs4850/sumII06/The%20syntax%20of%20C%20in%20Backus-Naur%20form.htm
      
      
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      c2f1846b
    • Masahiro Yamada's avatar
      genksyms: remove Makefile hack · a9529865
      Masahiro Yamada authored
      
      This workaround was introduced for suppressing the reduce/reduce conflict
      warnings because the %expect-rr directive, which is applicable only to GLR
      parsers, cannot be used for genksyms.
      
      Since there are no longer any conflicts, this Makefile hack is now
      unnecessary.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      a9529865
    • Masahiro Yamada's avatar
      genksyms: fix last 3 shift/reduce conflicts · 668de2b9
      Masahiro Yamada authored
      The genksyms parser has ambiguities in its grammar, which are currently
      suppressed by a workaround in scripts/genksyms/Makefile.
      
      Building genksyms with W=1 generates the following warnings:
      
          YACC    scripts/genksyms/parse.tab.[ch]
        scripts/genksyms/parse.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr]
        scripts/genksyms/parse.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
      
      The ambiguity arises when decl_specifier_seq is followed by '(' because
      the following two interpretations are possible:
      
        - decl_specifier_seq direct_abstract_declarator '(' parameter_declaration_clause ')'
        - decl_specifier_seq '(' abstract_declarator ')'
      
      This issue occurs because the current parser allows an empty string to
      be reduced to direct_abstract_declarator, which is incorrect.
      
      K&R [1] explains the correct grammar:
      
          <parameter-declaration> ::= {<declaration-specifier>}+ <declarator>
                                    | {<declaration-specifier>}+ <abstract-declarator>
                                    | {<declaration-specifier>}+
      
          <abstract-declarator> ::= <pointer>
                                  | <pointer> <direct-abstract-declarator>
                                  | <direct-abstract-declarator>
      
          <direct-abstract-declarator> ::=  ( <abstract-declarator> )
                                         | {<direct-abstract-declarator>}? [ {<constant-expression>}? ]
                                         | {<direct-abstract-declarator>}? ( {<parameter-type-list>}? )
      
      This commit resolves all remaining conflicts.
      
      We need to consider the difference between the following two examples:
      
      [Example 1] ( <abstract-declarator> ) can become <direct-abstract-declarator>
      
              void my_func(int (foo));
      
          ... is equivalent to:
      
              void my_func(int foo);
      
      [Example 2] ( <parameter-type-list> ) can become <direct-abstract-declarator>
      
              typedef int foo;
              void my_func(int (foo));
      
          ... is equivalent to:
      
              void my_func(int (*callback)(int));
      
      Please note that the function declaration is identical in both examples,
      but the preceding typedef creates the distinction. I introduced a new
      term, open_paren, to enable the type lookup immediately after the '('
      token. Without this, we cannot distinguish between [Example 1] and
      [Example 2].
      
      [1]: https://cs.wmich.edu/~gupta/teaching/cs4850/sumII06/The%20syntax%20of%20C%20in%20Backus-Naur%20form.htm
      
      
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      668de2b9
    • Masahiro Yamada's avatar
      genksyms: fix 6 shift/reduce conflicts and 5 reduce/reduce conflicts · 3ccda63a
      Masahiro Yamada authored
      
      The genksyms parser has ambiguities in its grammar, which are currently
      suppressed by a workaround in scripts/genksyms/Makefile.
      
      Building genksyms with W=1 generates the following warnings:
      
          YACC    scripts/genksyms/parse.tab.[ch]
        scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
        scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]
        scripts/genksyms/parse.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
      
      The comment in the parser describes the current problem:
      
          /* This wasn't really a typedef name but an identifier that
             shadows one.  */
      
      Consider the following simple C code:
      
          typedef int foo;
          void my_func(foo foo) {}
      
      In the function parameter list (foo foo), the first 'foo' is a type
      specifier (typedef'ed as 'int'), while the second 'foo' is an identifier.
      
      However, the lexer cannot distinguish between the two. Since 'foo' is
      already typedef'ed, the lexer returns TYPE for both instances, instead
      of returning IDENT for the second one.
      
      To support shadowed identifiers, TYPE can be reduced to either a
      simple_type_specifier or a direct_abstract_declarator, which creates
      a grammatical ambiguity.
      
      Without analyzing the grammar context, it is very difficult to resolve
      this correctly.
      
      This commit introduces a flag, dont_want_type_specifier, which allows
      the parser to inform the lexer whether an identifier is expected. When
      dont_want_type_specifier is true, the type lookup is suppressed, and
      the lexer returns IDENT regardless of any preceding typedef.
      
      After this commit, only 3 shift/reduce conflicts will remain.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarNicolas Schier <n.schier@avm.de>
      3ccda63a
  13. Jan 17, 2025
  14. Jan 16, 2025
  15. Jan 13, 2025
    • Shivam Chaudhary's avatar
      kernel-wide: add explicity||explicitly to spelling.txt · 93b6bd40
      Shivam Chaudhary authored
      Correct the spelling dictionary so that future instances will be caught by
      checkpatch, and fix the instances found.
      
      Link: https://lkml.kernel.org/r/20241211154903.47027-1-cvam0000@gmail.com
      
      
      Signed-off-by: default avatarShivam Chaudhary <cvam0000@gmail.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Leon Romanovsky <leon@kernel.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Naveen N Rao <naveen@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Shivam Chaudhary <cvam0000@gmail.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      93b6bd40
    • Easwar Hariharan's avatar
      coccinelle: misc: add secs_to_jiffies script · 551dbd1e
      Easwar Hariharan authored
      This script finds and suggests conversions of timeout patterns that result
      in seconds-denominated timeouts to use the new secs_to_jiffies() API in
      include/linux/jiffies.h for better readability.
      
      Link: https://lkml.kernel.org/r/20241210-converge-secs-to-jiffies-v3-2-ddfefd7e9f2a@linux.microsoft.com
      
      
      Signed-off-by: default avatarEaswar Hariharan <eahariha@linux.microsoft.com>
      Suggested-by: default avatarAnna-Maria Behnsen <anna-maria@linutronix.de>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Andrew Lunn <andrew+netdev@lunn.ch>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Daniel Mack <daniel@zonque.org>
      Cc: David Airlie <airlied@gmail.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Dick Kennedy <dick.kennedy@broadcom.com>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Florian Fainelli <florian.fainelli@broadcom.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ilya Dryomov <idryomov@gmail.com>
      Cc: Jack Wang <jinpu.wang@cloud.ionos.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: James Smart <james.smart@broadcom.com>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Cc: Jeff Johnson <jjohnson@kernel.org>
      Cc: Jeff Johnson <quic_jjohnson@quicinc.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Jeroen de Borst <jeroendb@google.com>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Joe Lawrence <joe.lawrence@redhat.com>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Jozsef Kadlecsik <kadlec@netfilter.org>
      Cc: Julia Lawall <julia.lawall@inria.fr>
      Cc: Kalle Valo <kvalo@kernel.org>
      Cc: Louis Peens <louis.peens@corigine.com>
      Cc: Lucas De Marchi <lucas.demarchi@intel.com>
      Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Miroslav Benes <mbenes@suse.cz>
      Cc: Naveen N Rao <naveen@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Nicolas Palix <nicolas.palix@imag.fr>
      Cc: Oded Gabbay <ogabbay@kernel.org>
      Cc: Ofir Bitton <obitton@habana.ai>
      Cc: Pablo Neira Ayuso <pablo@netfilter.org>
      Cc: Paolo Abeni <pabeni@redhat.com>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Praveen Kaligineedi <pkaligineedi@google.com>
      Cc: Ray Jui <rjui@broadcom.com>
      Cc: Robert Jarzmik <robert.jarzmik@free.fr>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Roger Pau Monné <roger.pau@citrix.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Scott Branden <sbranden@broadcom.com>
      Cc: Shailend Chand <shailend@google.com>
      Cc: Simona Vetter <simona@ffwll.ch>
      Cc: Simon Horman <horms@kernel.org>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Takashi Iwai <tiwai@suse.com>
      Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Xiubo Li <xiubli@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      551dbd1e
    • Tamir Duberstein's avatar
      checkpatch: check return of `git_commit_info` · 3735c522
      Tamir Duberstein authored
      Avoid string concatenation with an undefined variable when a reference to
      a missing commit is contained in a `Fixes` tag.
      
      Given this patch:
      
      : From: Tamir Duberstein <tamird@gmail.com>
      : Subject: Test patch
      : Date: Fri, 25 Oct 2024 19:30:51 -0400
      :
      : This is a test patch.
      :
      : Fixes: deadbeef111
      : Signed-off-by: Tamir Duberstein <tamird@gmail.com>
      : --- /dev/null
      : +++ b/new-file
      : @@ -0,0 +1 @@
      : +Test.
      
      Before:
      
      WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes:  ("commit title")'
      WARNING: Unknown commit id 'deadbeef111', maybe rebased or not pulled?
      Use of uninitialized value $cid in concatenation (.) or string at scripts/checkpatch.pl line 3242.
      
      After:
      
      WARNING: Unknown commit id 'deadbeef111', maybe rebased or not pulled?
      
      This patch also reduce duplication slightly.
      
      [akpm@linux-foundation.org: s/12 chars of sha1/12+ chars of sha1/, per Jon]
        Link: https://lkml.kernel.org/r/87o70kt232.fsf@trenco.lwn.net
      Link: https://lkml.kernel.org/r/20241204-checkpatch-missing-commit-v1-1-68b34c94944e@gmail.com
      
      
      Signed-off-by: default avatarTamir Duberstein <tamird@gmail.com>
      Cc: Andy Whitcroft <apw@canonical.com>
      Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      3735c522
Loading