public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Kitt <steve@sk2.org>
To: Alejandro Colomar <alx.manpages@gmail.com>,
	Michael Kerrisk <mtk.manpages@gmail.com>
Cc: linux-man@vger.kernel.org, Stephen Kitt <steve@sk2.org>
Subject: [PATCH 5/5] strtok.3: Fix j/str1 declaration
Date: Sat,  8 Jan 2022 16:43:04 +0100	[thread overview]
Message-ID: <20220108154304.1030478-5-steve@sk2.org> (raw)
In-Reply-To: <20220108154304.1030478-1-steve@sk2.org>

    for (int j = 1, str1 = argv[1]; ...

declares two variables of type int, j and str1; the pre-existing
char * str1 isn't used. This causes compiler warnings. Declaring j
outside the loop fixes everything.

Signed-off-by: Stephen Kitt <steve@sk2.org>
---
 man3/strtok.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/man3/strtok.3 b/man3/strtok.3
index aec914094..06e9688b6 100644
--- a/man3/strtok.3
+++ b/man3/strtok.3
@@ -255,6 +255,7 @@ main(int argc, char *argv[])
 {
     char *str1, *str2, *token, *subtoken;
     char *saveptr1, *saveptr2;
+    int j;
 
     if (argc != 4) {
         fprintf(stderr, "Usage: %s string delim subdelim\en",
@@ -262,7 +263,7 @@ main(int argc, char *argv[])
         exit(EXIT_FAILURE);
     }
 
-    for (int j = 1, str1 = argv[1]; ; j++, str1 = NULL) {
+    for (j = 1, str1 = argv[1]; ; j++, str1 = NULL) {
         token = strtok_r(str1, argv[2], &saveptr1);
         if (token == NULL)
             break;
-- 
2.30.2


  parent reply	other threads:[~2022-01-08 16:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-08 15:43 [PATCH 1/5] mq_notify.3: Add signal.h for SIGEV_ constants Stephen Kitt
2022-01-08 15:43 ` [PATCH 2/5] newlocale.3: Use LC_GLOBAL_LOCALE, not ..._HANDLE Stephen Kitt
2022-01-08 19:44   ` Alejandro Colomar (man-pages)
2022-01-08 15:43 ` [PATCH 3/5] pkeys.7: Update the example to match glibc Stephen Kitt
2022-01-08 19:49   ` Alejandro Colomar (man-pages)
2022-01-08 15:43 ` [PATCH 4/5] pkeys.7: Rely on the glibc implementations Stephen Kitt
2022-01-08 15:43 ` Stephen Kitt [this message]
2022-01-08 19:51   ` [PATCH 5/5] strtok.3: Fix j/str1 declaration Alejandro Colomar (man-pages)
2022-01-08 16:02 ` [PATCH 1/5] mq_notify.3: Add signal.h for SIGEV_ constants Stephen Kitt
2022-01-08 19:42 ` Alejandro Colomar (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220108154304.1030478-5-steve@sk2.org \
    --to=steve@sk2.org \
    --cc=alx.manpages@gmail.com \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox