git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/3] send-email: use "return;" not "return undef;" on error codepaths

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Apr 1, 2013, 04:08 UTC
Message-ID
<CAPig+cTzre7D93TOv9CV_qhX6hnxSmj_zL+mewKE5c9kaP+-Pg@mail.gmail.com>
In-Reply-To
<1364780442-6015-1-git-send-email-gitster@pobox.com>
On Sun, Mar 31, 2013 at 9:40 PM, Junio C Hamano <gitster@pobox.com> wrote:
> All the callers of "ask", "extract_valid_address", and "validate_patch"
> subroutines assign the return values from them to a single scaler:
s/scaler/scalar/g
(note the /g)
Show 16 quoted lines
>
>         $var = subr(...);
>
> and "return undef;" in these subroutine can safely be turned into a
> simpler "return;".  Doing so will also future-proof a new caller that
> mistakenly does this:
>
>     @foo = ask(...);
>     if (@foo) { ... we got an answer ... } else { ... we did not ... }
>
> Note that we leave "return undef;" in validate_address on purpose,
> even though Perlcritic may complain.  The primary "return" site of
> the function returns whatever is in the scaler variable $address, so
> it is pointless to change only the other "return undef;" to "return".
> The caller must be prepared to see an array with a single undef as
> the return value from this subroutine anyway.
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 18 of 21 in “git-send-email.perl: implement suggestions made by perlcritic”
  1. git-send-email.perl: implement suggestions made by perlcriticRamkumar Ramachandra, Mar 21, 2013
  2. Junio C HamanoMar 21, 2013
  3. Ramkumar RamachandraMar 21, 2013
  4. Ramkumar RamachandraMar 27, 2013
  5. Junio C HamanoMar 27, 2013
  6. git-send-email.perl: implement suggestions made by perlcriticRamkumar Ramachandra, Mar 28, 2013
  7. Jonathan NiederMar 28, 2013
  8. Junio C HamanoMar 28, 2013
  9. Ramkumar RamachandraMar 31, 2013
  10. Junio C HamanoApr 1, 2013
  11. 1/3 send-email: use "return;" not "return undef;" on error codepathsJunio C Hamano, Apr 1, 2013
  12. 2/3 send-email: drop misleading function prototypeJunio C Hamano, Apr 1, 2013
  13. Jonathan NiederApr 1, 2013
  14. Eric SunshineApr 1, 2013
  15. 3/3 send-email: use the three-arg form of open in recipients_cmdJunio C Hamano, Apr 1, 2013
  16. Jonathan NiederApr 1, 2013
  17. Ramkumar RamachandraApr 2, 2013
  18. Eric SunshineApr 1, 2013
  19. Ramkumar RamachandraApr 2, 2013
  20. Junio C HamanoApr 2, 2013
  21. Ramkumar RamachandraApr 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.