does true.c need command line arguments?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

does true.c need command line arguments?

Ali H. Fardan
I'm just wondering if true.c does really need int argc and char *argv[]
rather than void (src/usr.bin/true/true.c), if not:

Index: true.c
===================================================================
RCS file: /cvs/src/usr.bin/true/true.c,v
retrieving revision 1.1
diff -r1.1 true.c
6c6
< main(int argc, char *argv[])
---
> main(void)

Reply | Threaded
Open this post in threaded view
|

Re: does true.c need command line arguments?

Theo de Raadt
Absolutely no way for your change.

It is correct.

> I'm just wondering if true.c does really need int argc and char *argv[]
> rather than void (src/usr.bin/true/true.c), if not:
>
> Index: true.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/true/true.c,v
> retrieving revision 1.1
> diff -r1.1 true.c
> 6c6
> < main(int argc, char *argv[])
> ---
> > main(void)
>

Reply | Threaded
Open this post in threaded view
|

Re: does true.c need command line arguments?

Theo de Raadt
In reply to this post by Ali H. Fardan
> On 2016-07-04 22:17, Theo de Raadt wrote:
> > Absolutely no way for your change.
> >
> > It is correct.
> >
> >> I'm just wondering if true.c does really need int argc and char
> >> *argv[]
> >> rather than void (src/usr.bin/true/true.c), if not:
> >>
> >> Index: true.c
> >> ===================================================================
> >> RCS file: /cvs/src/usr.bin/true/true.c,v
> >> retrieving revision 1.1
> >> diff -r1.1 true.c
> >> 6c6
> >> < main(int argc, char *argv[])
> >> ---
> >> > main(void)
> >>
>
> I didn't get it, could you explain why the main function should have
> these arguments since the program does not have to parse command line
> arguments?

Because main() is specified to take those arguments.

And also... because your proposal fixes absolutely nothing.

Reply | Threaded
Open this post in threaded view
|

Re: does true.c need command line arguments?

Simon Ruderich
On Mon, Jul 04, 2016 at 03:04:32PM -0600, Theo de Raadt wrote:
> Because main() is specified to take those arguments.

For what it's worth, the C-standard [1] specifies both versions:
int main(void) and int main(int argc, char *argv[]).

Regards
Simon

[1]: C11-draft, section 5.1.2.2.1
--
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

signature.asc (836 bytes) Download Attachment