# [PATCH] imap-send: cleanup execl() call to use NULL sentinel instead of 0

3 messages from 2006-03-11 to 2006-03-11. Participants: Marco Roeland, Morten Welinder.
Thread: https://gitlist.dev/t/3630

## Marco Roeland, 2006-03-11 08:55

Subject: [PATCH] imap-send: cleanup execl() call to use NULL sentinel instead of 0
Message-ID: <20060311085550.GA32089@fiberbit.xs4all.nl>
URL: https://gitlist.dev/e/20060311085550.GA32089%40fiberbit.xs4all.nl

```
Some versions of gcc check that calls to the exec() family have the proper
sentinel for variadic calls. This should be (char *) NULL according to the
man page. Although for all other purposes the 0 is equivalent, gcc
nevertheless does emit a warning for 0 and not for NULL. This also makes the
usage consistent throughout git.

The whitespace in function calls throughout imap-send.c has its own style,
so I left it that way.

---

 imap-send.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

db1a0875cbc28970208e7a2fbb93d680d8ffe572
diff --git a/imap-send.c b/imap-send.c
index fddaac0..203284d 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -945,7 +945,7 @@ imap_open_store( imap_server_conf_t *srv
 				_exit( 127 );
 			close( a[0] );
 			close( a[1] );
-			execl( "/bin/sh", "sh", "-c", srvc->tunnel, 0 );
+			execl( "/bin/sh", "sh", "-c", srvc->tunnel, NULL );
 			_exit( 127 );
 		}
 
-- 
1.2.4.ge29f
Marco Roeland

```

## Morten Welinder, 2006-03-11 14:01

Subject: Re: [PATCH] imap-send: cleanup execl() call to use NULL sentinel instead of 0
Message-ID: <118833cc0603110601x6ac9b2b6kaa0277981c6dd44b@mail.gmail.com>
URL: https://gitlist.dev/e/118833cc0603110601x6ac9b2b6kaa0277981c6dd44b%40mail.gmail.com
In-Reply-To: <20060311085550.GA32089@fiberbit.xs4all.nl>

```
If you're going to fix that, you should use (char *)NULL or
(char *)0, just in case you end up on a machine where
NULL doesn't a pointer type.

(Yup, NULL can be a null pointer without having pointer type.)

M.

```

## Marco Roeland, 2006-03-11 20:30

Subject: Re: [PATCH] imap-send: cleanup execl() call to use NULL sentinel instead of 0
Message-ID: <20060311203022.GA1578@fiberbit.xs4all.nl>
URL: https://gitlist.dev/e/20060311203022.GA1578%40fiberbit.xs4all.nl
In-Reply-To: <118833cc0603110601x6ac9b2b6kaa0277981c6dd44b@mail.gmail.com>

```
On Saturday March 11th 2006 Morten Welinder wrote:

> If you're going to fix that, you should use (char *)NULL or
> (char *)0, just in case you end up on a machine where
> NULL doesn't a pointer type.
> 
> (Yup, NULL can be a null pointer without having pointer type.)

For gcc NULL is specifically always guaranteed to be a valid sentinel.
And it was basically just about fixing the gcc warning, no pedantics
intended! All other uses within git for the exec() family also use plain
uncast NULL, which looks better anyway.

Strictly speaking you're probably right, but there's a chance that this
will generate warnings on other compilers.

And if you should use a compiler with a weird notion of NULL, you're
probably better off switching compilers immediately. ;-)
-- 
Marco Roeland

```
