[PATCH 17/25] avoid segfault when calling sanitize_string() on NULL

2011-06-03 Thread Carl Worth
On Sat, 28 May 2011 14:51:52 -0700, Jameson Graef Rollins  wrote:
> +if (NULL == str)
> + return NULL;

I haven't been blocking patches because of this, but can I please ask
everyone to not use the above style?

I understand that the above style is intended to generate a compiler
error in the case of the programmer mistyping '=' where '==' was
intended.

But I just can't stand this style.

It looks so unnatural to me to read "if some_value is some_variable"
instead of the natural "if some_variable is some_value".

Also, gcc is kind enough to warn ("suggest parentheses around assignment
used as truth value") in the case of "if (str = NULL)" anyway, so
there's no actual benefit to the unnatural style.

I really do want our code to be readable, and I think that little things
do make a difference.

Thanks for your attention, (and thanks for your patience if I seem off
my rocker).

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



Re: [PATCH 17/25] avoid segfault when calling sanitize_string() on NULL

2011-06-03 Thread Carl Worth
On Sat, 28 May 2011 14:51:52 -0700, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 +if (NULL == str)
 + return NULL;

I haven't been blocking patches because of this, but can I please ask
everyone to not use the above style?

I understand that the above style is intended to generate a compiler
error in the case of the programmer mistyping '=' where '==' was
intended.

But I just can't stand this style.

It looks so unnatural to me to read if some_value is some_variable
instead of the natural if some_variable is some_value.

Also, gcc is kind enough to warn (suggest parentheses around assignment
used as truth value) in the case of if (str = NULL) anyway, so
there's no actual benefit to the unnatural style.

I really do want our code to be readable, and I think that little things
do make a difference.

Thanks for your attention, (and thanks for your patience if I seem off
my rocker).

-Carl


pgppLGJuKMVtv.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 17/25] avoid segfault when calling sanitize_string() on NULL

2011-05-28 Thread Jameson Graef Rollins
From: Daniel Kahn Gillmor 

Signed-off-by: Jameson Graef Rollins 
---
 notmuch-search.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index 530cecc..616fe68 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -116,6 +116,9 @@ sanitize_string (const void *ctx, const char *str)
 {
 char *out, *loop;

+if (NULL == str)
+   return NULL;
+
 loop = out = talloc_strdup (ctx, str);

 for (; *loop; loop++) {
-- 
1.7.4.4