threads / patch / 55632

patchFix a small flaw in the comment of strmap.h

Subject: [PATCH] Fix a small flaw in the comment of strmap.h

## tl;dr

3 messages between May 6, 2021 and May 6, 2021. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Teng Long· May 6, 2021, 08:19 UTC · lore
Signed-off-by: Teng Long <dyroneteng@gmail.com>
---
 strmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to strmap.h +1 −1
diff --git a/strmap.h b/strmap.h
index 1e152d832d..0d1d00d14e 100644
--- a/strmap.h
+++ b/strmap.h
@@ -78,7 +78,7 @@ struct strmap_entry *strmap_get_entry(struct strmap *map, const char *str);
 void *strmap_get(struct strmap *map, const char *str);
 
 /*
- * Return non-zero iff "str" is present in the map. This differs from
+ * Return non-zero if "str" is present in the map. This differs from
  * strmap_get() in that it can distinguish entries with a NULL data pointer.
  */
 int strmap_contains(struct strmap *map, const char *str);
-- 
2.31.1
Junio C Hamano· May 6, 2021, 08:46 UTC · re: Teng Long · lore

Re: [PATCH] Fix a small flaw in the comment of strmap.h

Teng Long <dyroneteng@gmail.com> writes:
> Subject: Re: [PATCH] Fix a small flaw in the comment of strmap.h
cf. Documentation/SubmittingPatches::summary-section
Show 15 quoted lines
> Signed-off-by: Teng Long <dyroneteng@gmail.com>
> ---
>  strmap.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/strmap.h b/strmap.h
> index 1e152d832d..0d1d00d14e 100644
> --- a/strmap.h
> +++ b/strmap.h
> @@ -78,7 +78,7 @@ struct strmap_entry *strmap_get_entry(struct strmap *map, const char *str);
>  void *strmap_get(struct strmap *map, const char *str);
>  
>  /*
> - * Return non-zero iff "str" is present in the map. This differs from
> + * Return non-zero if "str" is present in the map. This differs from

The original is correct; this function returns a non-zero value if and only if (iff is a common abbreviation for this expression) "str" is in the map, implying that when "str" is not in the map, the caller can rest assured that the function will not return a non-zero value (in other words, the caller is guaranteed to receive zero).

If you change that to "if", the comment no longer says what happens when "str" is *not* present in the map, which is making it worse.

dyrone teng· May 6, 2021, 08:49 UTC · re: Junio C Hamano · lore

Re: [PATCH] Fix a small flaw in the comment of strmap.h

Show 5 quoted lines
>The original is correct; this function returns a non-zero value if
>and only if (iff is a common abbreviation for this expression) "str"
>is in the map, implying that when "str" is not in the map, the
>caller can rest assured that the function will not return a non-zero
>value (in other words, the caller is guaranteed to receive zero).
>If you change that to "if", the comment no longer says what happens
>when "str" is *not* present in the map, which is making it worse.
Thanks, got it.
Junio C Hamano <gitster@pobox.com> 于2021年5月6日周四 下午4:46写道:
Show 31 quoted lines
>
> Teng Long <dyroneteng@gmail.com> writes:
>
> > Subject: Re: [PATCH] Fix a small flaw in the comment of strmap.h
>
> cf. Documentation/SubmittingPatches::summary-section
>
> > Signed-off-by: Teng Long <dyroneteng@gmail.com>
> > ---
> >  strmap.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/strmap.h b/strmap.h
> > index 1e152d832d..0d1d00d14e 100644
> > --- a/strmap.h
> > +++ b/strmap.h
> > @@ -78,7 +78,7 @@ struct strmap_entry *strmap_get_entry(struct strmap *map, const char *str);
> >  void *strmap_get(struct strmap *map, const char *str);
> >
> >  /*
> > - * Return non-zero iff "str" is present in the map. This differs from
> > + * Return non-zero if "str" is present in the map. This differs from
>
> The original is correct; this function returns a non-zero value if
> and only if (iff is a common abbreviation for this expression) "str"
> is in the map, implying that when "str" is not in the map, the
> caller can rest assured that the function will not return a non-zero
> value (in other words, the caller is guaranteed to receive zero).
>
> If you change that to "if", the comment no longer says what happens
> when "str" is *not* present in the map, which is making it worse.

← back to recent threads