All of lore.kernel.org
 help / color / mirror / Atom feed
* getopt.3
@ 2014-11-11 22:27 Jonny Grant
       [not found] ` <CAGc9EveyW=7Oy2NBfy+V2kjEHhzxkY5Keh2+eU_hff8kbBQt9Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Jonny Grant @ 2014-11-11 22:27 UTC (permalink / raw)
  To: Michael Kerrisk; +Cc: linux-man

http://man7.org/linux/man-pages/man3/getopt.3.html

Hello

I noticed that "nsecs = 0;" is not needed in the getopt source code example.

GCC gives warning about this variable being initialised.

Regards, Jonny
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: getopt.3
       [not found] ` <CAGc9EveyW=7Oy2NBfy+V2kjEHhzxkY5Keh2+eU_hff8kbBQt9Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-04-12  7:21   ` Michael Kerrisk (man-pages)
       [not found]     ` <CAGc9EvfEfGEfw5Fr3tvoJxrRbTJzps9y=Xbt0G4cZxeU1OSk-Q@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Kerrisk (man-pages) @ 2015-04-12  7:21 UTC (permalink / raw)
  To: Jonny Grant; +Cc: linux-man

Hello Jonny,

On 11 November 2014 at 23:27, Jonny Grant <jg-hus3n9K41k0@public.gmane.org> wrote:
> http://man7.org/linux/man-pages/man3/getopt.3.html
>
> Hello
>
> I noticed that "nsecs = 0;" is not needed in the getopt source code example.
>
> GCC gives warning about this variable being initialised.

But it is used:

           printf("flags=%d; tfnd=%d; nsecs=%d; optind=%d\n",
                   flags, tfnd, nsecs, optind)

Am I missing the point of your report?

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: getopt.3
       [not found]         ` <5548CF67.3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-05-08 21:49           ` Jonny Grant
  0 siblings, 0 replies; 3+ messages in thread
From: Jonny Grant @ 2015-05-08 21:49 UTC (permalink / raw)
  To: Michael Kerrisk (man-pages); +Cc: linux-man



On 05/05/15 15:10, Michael Kerrisk (man-pages) wrote:
> On 05/01/2015 12:10 AM, Jonny Grant wrote:
>> #include <unistd.h>
>> #include <stdlib.h>
>> #include <stdio.h>
>>
>> int
>>         main(int argc, char *argv[])
>> {
>>     int flags, opt;
>>     int nsecs, tfnd;
>>
>>     nsecs = 0;
>>     tfnd = 0;
>>     flags = 0;
>>     while ((opt = getopt(argc, argv, "nt:")) != -1) {
>>         switch (opt) {
>>         case 'n':
>>             flags = 1;
>>             break;
>>         case 't':
>>             nsecs = atoi(optarg);
>>             tfnd = 1;
>>             break;
>>         default: /* '?' */
>>             fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\n",
>>                     argv[0]);
>>             exit(EXIT_FAILURE);
>>         }
>>     }
>>
>>      return 0;
>> }
>
> It looks like you are looking at a (very) old version
> of the page. That code does not match the example in
> the current man page.

Apologies, unsure where I got that old code from.
Latest code compiles ok for me too.
Regards, Jonny
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-08 21:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-11 22:27 getopt.3 Jonny Grant
     [not found] ` <CAGc9EveyW=7Oy2NBfy+V2kjEHhzxkY5Keh2+eU_hff8kbBQt9Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-04-12  7:21   ` getopt.3 Michael Kerrisk (man-pages)
     [not found]     ` <CAGc9EvfEfGEfw5Fr3tvoJxrRbTJzps9y=Xbt0G4cZxeU1OSk-Q@mail.gmail.com>
     [not found]       ` <5548CF67.3@gmail.com>
     [not found]         ` <5548CF67.3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-08 21:49           ` getopt.3 Jonny Grant

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.