From 9f5dce80702d494535ab332273d20da1f9ca4365 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Tue, 17 Feb 2015 08:46:56 +0100 Subject: maint: prefer STREQ_LEN and STRPREFIX over strncmp in all cases * cfg.mk (sc_prohibit_strncmp): Improve the search pattern: use _sc_search_regexp to find all invocations of strncmp except when used on a macro definition line; just match the function name with an opening parenthesis. Before, the expression missed places where the comparison against 0 was in a subsequent line. * src/system.h (STRNCMP_LIT): Shorten 'literal' to 'lit' to move the whole definition of the macro into one line - thus making sc_prohibit_strncmp pass. (STRPREFIX): Add space before parenthesis. * src/du.c (main): Prefer STREQ_LEN over strncmp. * src/pinky.c (scan_entries): Likewise. * src/tac.c (tac_seekable): Likewise. * src/who.c (scan_entries): Likewise. --- src/pinky.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/pinky.c') diff --git a/src/pinky.c b/src/pinky.c index f1bf3407c..71650bfae 100644 --- a/src/pinky.c +++ b/src/pinky.c @@ -445,8 +445,7 @@ scan_entries (size_t n, const STRUCT_UTMP *utmp_buf, int i; for (i = 0; i < argc_names; i++) - if (strncmp (UT_USER (utmp_buf), argv_names[i], UT_USER_SIZE) - == 0) + if (STREQ_LEN (UT_USER (utmp_buf), argv_names[i], UT_USER_SIZE)) { print_entry (utmp_buf); break; -- cgit v1.2.3-54-g00ecf