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

[PATCH 4/6] Add explict return to end of subroutines

From
BPBill Pemberton <wfp5p@virginia.edu>
Date
Apr 29, 2009, 13:12 UTC
Message-ID
<1241010743-7020-5-git-send-email-wfp5p@virginia.edu>
In-Reply-To
<1241010743-7020-4-git-send-email-wfp5p@virginia.edu>

In perl a subroutine that ends without an explicit return will return the value of the last expression evalutated. This can lead to unexpected return values.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
---
 git-send-email.perl |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 1ed5869..c24e0df 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -160,6 +160,7 @@ my $compose_filename;
 # Handle interactive edition of files.
 my $multiedit;
 my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
+
 sub do_edit {
 	if (defined($multiedit) && !$multiedit) {
 		map {
@@ -174,6 +175,7 @@ sub do_edit {
 			die("the editor exited uncleanly, aborting everything");
 		}
 	}
+    return;
 }
 
 # Variables with corresponding config settings
@@ -304,6 +306,7 @@ sub read_config {
 			$smtp_encryption = 'ssl';
 		}
 	}
+    return;
 }
 
 # read configuration from [sendemail "$identity"], fall back on [sendemail]
@@ -745,6 +748,7 @@ sub make_message_id
 	my $message_id_template = "<%s-git-send-email-%s>";
 	$message_id = sprintf($message_id_template, $uniq, $du_part);
 	#print "new message id = $message_id\n"; # Was useful for debugging
+    return;
 }
 
 
@@ -971,6 +975,7 @@ X-Mailer: git-send-email $gitversion
 			print "Result: OK\n";
 		}
 	}
+   return;
 }
 
 $reply_to = $initial_reply_to;
@@ -1149,6 +1154,7 @@ cleanup_compose_files();
 
 sub cleanup_compose_files {
 	unlink($compose_filename, $compose_filename . ".final") if $compose;
+        return;
 }
 
 $smtp->quit if $smtp;
-- 
1.6.0.6
Previous: Bill PembertonNext: Bill Pemberton
Message 5 of 24 in “cleanups for git-send-email”
  1. 0/6 cleanups for git-send-emailBill Pemberton, Apr 29, 2009
  2. 1/6 Remove return undef from validate_patchBill Pemberton, Apr 29, 2009
  3. 2/6 Remove function prototypes from git-send-email.perlBill Pemberton, Apr 29, 2009
  4. 3/6 Remove return undef from ask()Bill Pemberton, Apr 29, 2009
  5. 4/6 Add explict return to end of subroutinesBill Pemberton, Apr 29, 2009
  6. 5/6 Remove mix of high and low-precedence booleansBill Pemberton, Apr 29, 2009
  7. 6/6 Remove bareword filehandles in git-send-email.perlBill Pemberton, Apr 29, 2009
  8. Jeff KingMay 3, 2009
  9. Francis GaliegueMay 3, 2009
  10. H.Merijn BrandMay 4, 2009
  11. Francis GaliegueMay 4, 2009
  12. H.Merijn BrandMay 4, 2009
  13. 5/6 Re: Remove mix of high and low-precedence booleansNicolas Sebrecht, Apr 29, 2009
  14. Bill PembertonApr 29, 2009
  15. Jeff KingMay 3, 2009
  16. Jeff KingMay 3, 2009
  17. Jay SoffianMay 4, 2009
  18. Jeff KingMay 3, 2009
  19. Jeff KingMay 3, 2009
  20. Junio C HamanoApr 29, 2009
  21. Bill PembertonApr 29, 2009
  22. Junio C HamanoApr 29, 2009
  23. 0/6 Re: cleanups for git-send-emailNicolas Sebrecht, Apr 29, 2009
  24. Andreas EricssonApr 30, 2009

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.