[PATCH 5/5] strtok.3: Fix j/str1 declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



    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@xxxxxxx>
---
 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




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux