Add streq(3), and use it to replace confusing uses of strncmp(3)
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 3 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | string: Add streq()drivers/ drivers/ include/ +1 more | +25 | 0 replies | |
| 2/4 | tools/: Add streq() to nolibc/stringtools/ tools/ tools/ | +2 | 0 replies | |
| 3/4 | treewide: Use streq(3) instead of confusing uses of strncmp(3)arch/ arch/ arch/ +6 more | +18 | 0 replies | |
| 4/4 | treewide: Use streq(3) instead of unnecessary uses of strncmp(3)arch/ drivers/ drivers/ +11 more | +20 | 2 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH v1 0/4] Add streq(3), and use it to replace confusing uses of strncmp(3)
Hi!
This is a spin off from the patch set that adds strprefix()[1]. This patch set replaces some uses of strncmp(3), so that later the strprefix() patch set is easier to apply.
[1]: <https://lore.kernel.org/linux-hardening/[email protected]/T/>
This patch set doesn't replace strcmp(3) with streq(3), since there are thousands of those, and those are less important now. The strncmp(3) ones are the most important, because they can be easily confused with strprefix().
Testing
~~~~~~~
(I've indented the output, to better see the commands.)
$ git log --oneline --graph v7.4-rc1^..streq1 * 7994b5827030 (HEAD -> streq, tag: streq1) treewide: Use streq(3) instead of unnecessary uses of strncmp(3) * b93e0d005739 treewide: Use streq(3) instead of confusing uses of strncmp(3) * 1715e2c9c8ea tools/: Add streq() to nolibc/string * ad8500a6eb0a string: Add streq() * 6628e7d4c6b2 (tag: v7.4-rc1, master) Linux 7.4-rc1 $ cp ../kunitconfig .kunitconfig $ cat .kunitconfig CONFIG_KUNIT=y CONFIG_STRING_KUNIT_TEST=y $ mkdir -p ~/tmp/streq1 $ export TMPDIR=$HOME/tmp/streq1/ $ ./tools/testing/kunit/kunit.py run "string*" [18:45:10] Configuring KUnit Kernel ... Generating .config ... Populating config with: $ make ARCH=um O=.kunit olddefconfig [18:45:14] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=24 [18:45:30] Starting KUnit Kernel (1/1)... [18:45:30] ============================================================ Running tests with: $ .kunit/linux 'kunit.filter_glob=string*' kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [18:45:30] ============= string-stream-test (12 subtests) ============= [18:45:30] [PASSED] string_stream_managed_init_test [18:45:30] [PASSED] string_stream_unmanaged_init_test [18:45:30] [PASSED] string_stream_managed_free_test [18:45:30] [PASSED] string_stream_resource_free_test [18:45:30] [PASSED] string_stream_line_add_test [18:45:30] [PASSED] string_stream_variable_length_line_test [18:45:30] [PASSED] string_stream_append_test [18:45:30] [PASSED] string_stream_append_auto_newline_test [18:45:30] [PASSED] string_stream_append_empty_string_test [18:45:30] [PASSED] string_stream_no_auto_newline_test [18:45:30] [PASSED] string_stream_auto_newline_test [18:45:30] [PASSED] string_stream_performance_test [18:45:30] =============== [PASSED] string-stream-test ================ [18:45:30] =================== string (29 subtests) =================== [18:45:30] [PASSED] string_test_memset16 [18:45:30] [PASSED] string_test_memset32 [18:45:30] [PASSED] string_test_memset64 [18:45:30] [PASSED] string_test_strlen [18:45:30] [PASSED] string_test_strnlen [18:45:30] [PASSED] string_test_strchr [18:45:30] [PASSED] string_test_strnchr [18:45:30] [PASSED] string_test_strrchr [18:45:30] [PASSED] string_test_strspn [18:45:30] [PASSED] string_test_streq [18:45:30] [PASSED] string_test_strcmp [18:45:30] [PASSED] string_test_strcmp_long_strings [18:45:30] [PASSED] string_test_strncmp [18:45:30] [PASSED] string_test_strncmp_long_strings [18:45:30] [PASSED] string_test_strcasecmp [18:45:30] [PASSED] string_test_strcasecmp_long_strings [18:45:30] [PASSED] string_test_strncasecmp [18:45:30] [PASSED] string_test_strncasecmp_long_strings [18:45:30] [PASSED] string_test_strscpy [18:45:30] [PASSED] string_test_strcat [18:45:30] [PASSED] string_test_strncat [18:45:30] [PASSED] string_test_strlcat [18:45:30] [PASSED] string_test_strtomem [18:45:30] [PASSED] string_test_memtostr [18:45:30] [PASSED] string_test_strends [18:45:30] [SKIPPED] string_bench_strlen (not enabled) [18:45:30] [SKIPPED] string_bench_strnlen (not enabled) [18:45:30] [SKIPPED] string_bench_strchr (not enabled) [18:45:30] [SKIPPED] string_bench_strrchr (not enabled) [18:45:30] ===================== [PASSED] string ====================== [18:45:30] =============== string_helpers (4 subtests) ================ [18:45:30] [PASSED] test_get_size [18:45:30] [PASSED] test_upper_lower [18:45:30] [PASSED] test_unescape [18:45:30] [PASSED] test_escape [18:45:30] ================= [PASSED] string_helpers ================== [18:45:30] ============================================================ [18:45:30] Testing complete. Ran 45 tests: passed: 41, skipped: 4 [18:45:30] Elapsed time: 19.736s total, 3.261s configuring, 16.309s building, 0.162s running
$ make allmodconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o LEX scripts/kconfig/lexer.lex.c YACC scripts/kconfig/parser.tab.[ch] HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/menu.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTCC scripts/kconfig/util.o HOSTLD scripts/kconfig/conf # # configuration written to .config # $ time make -j24 | ts -s 00:00:00 GEN arch/x86/include/generated/asm/orc_hash.h 00:00:00 UPD arch/x86/include/generated/uapi/asm/bpf_perf_event.h 00:00:00 UPD arch/x86/include/generated/uapi/asm/errno.h ... 00:20:03 LD [M] net/qrtr/qrtr-tun.ko 00:20:03 LD [M] net/qrtr/qrtr-mhi.ko 00:20:03 LD [M] virt/lib/irqbypass.ko
real 20m3.221s user 425m2.307s sys 25m40.226s
Have a lovely night!
Alex
Alejandro Colomar (4):
string: Add streq()
tools/: Add streq() to nolibc/string
treewide: Use streq(3) instead of confusing uses of strncmp(3)
treewide: Use streq(3) instead of unnecessary uses of strncmp(3)
arch/arm/mach-omap2/sr_device.c | 8 ++++---- arch/m68k/sun3/prom/console.c | 6 +++--- arch/mips/bcm47xx/time.c | 2 +- arch/powerpc/kernel/security.c | 2 +- drivers/clk/socfpga/clk-gate-a10.c | 2 -- drivers/clk/socfpga/clk.h | 1 - drivers/edac/amd64_edac.c | 2 +- drivers/edac/i10nm_base.c | 2 +- drivers/edac/igen6_edac.c | 2 +- drivers/edac/imh_base.c | 2 +- drivers/edac/pnd2_edac.c | 2 +- drivers/edac/sb_edac.c | 2 +- drivers/edac/skx_base.c | 2 +- drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_ddp.c | 2 +- fs/ocfs2/filecheck.c | 6 +++--- include/linux/remoteproc/pruss.h | 2 +- include/linux/string.h | 12 ++++++++++++ lib/tests/string_kunit.c | 13 +++++++++++++ net/netfilter/xt_set.c | 2 +- sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 2 +- tools/bpf/bpftool/btf.c | 4 ++-- tools/include/nolibc/string.h | 2 ++ tools/perf/util/callchain.c | 8 ++++---- tools/perf/util/evsel.c | 3 +-- tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 8 ++++---- tools/testing/selftests/kvm/steal_time.c | 2 +- tools/testing/selftests/kvm/x86/xen_shinfo_test.c | 4 ++-- tools/testing/selftests/proc/proc-subset-pid.c | 5 ----- tools/testing/selftests/proc/proc.h | 5 ----- 30 files changed, 65 insertions(+), 52 deletions(-)
Range-diff against v0:
-: ------------ > 1: ad8500a6eb0a string: Add streq() -: ------------ > 2: 1715e2c9c8ea tools/: Add streq() to nolibc/string -: ------------ > 3: b93e0d005739 treewide: Use streq(3) instead of confusing uses of strncmp(3) -: ------------ > 4: 7994b5827030 treewide: Use streq(3) instead of unnecessary uses of strncmp(3)
Signature · 1 line
2.55.0