From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: [PATCH 14/28] cppcheck: Use inline suppressions for qrap.c Date: Wed, 28 Sep 2022 14:33:25 +1000 Message-ID: <20220928043339.613538-15-david@gibson.dropbear.id.au> In-Reply-To: <20220928043339.613538-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2639878471806661403==" --===============2639878471806661403== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit qrap.c uses several old-fashioned functions that cppcheck complains about. Since it's headed for obselesence anyway, just suppress these rather than attempting to modernize the code. Signed-off-by: David Gibson --- Makefile | 3 +-- qrap.c | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d5bfce4..d465d87 100644 --- a/Makefile +++ b/Makefile @@ -287,7 +287,7 @@ cppcheck: $(SRCS) $(HEADERS) --suppress=va_list_usedBeforeStarted:util.c \ --suppress=unusedFunction \ --suppress=knownConditionTrueFalse:conf.c \ - --suppress=strtokCalled:conf.c --suppress=strtokCalled:qrap.c \ + --suppress=strtokCalled:conf.c \ --suppress=localtimeCalled:pcap.c \ --suppress=unusedStructMember:pcap.c \ --suppress=unusedStructMember:dhcp.c \ @@ -295,7 +295,6 @@ cppcheck: $(SRCS) $(HEADERS) --suppress=unmatchedSuppression:conf.c \ --suppress=unmatchedSuppression:dhcp.c \ --suppress=unmatchedSuppression:pcap.c \ - --suppress=unmatchedSuppression:qrap.c \ --suppress=unmatchedSuppression:tcp.c \ --suppress=unmatchedSuppression:udp.c \ --suppress=unmatchedSuppression:util.c \ diff --git a/qrap.c b/qrap.c index a7d0645..3138386 100644 --- a/qrap.c +++ b/qrap.c @@ -179,12 +179,14 @@ int main(int argc, char **argv) char env_path[ARG_MAX + 1], *p, command[ARG_MAX]; strncpy(env_path, getenv("PATH"), ARG_MAX); + /* cppcheck-suppress strtokCalled */ p = strtok(env_path, ":"); while (p) { snprintf(command, ARG_MAX, "%s/%s", p, argv[2]); if (!access(command, X_OK)) goto valid_args; + /* cppcheck-suppress strtokCalled */ p = strtok(NULL, ":"); } } @@ -317,6 +319,7 @@ retry: */ if (retry_on_reset && rc == ECONNRESET) { retry_on_reset--; + /* cppcheck-suppress usleepCalled */ usleep(50 * 1000); goto retry; } -- 2.37.3 --===============2639878471806661403==--