Thread (31 messages) flat view 31 messages, 3 authors, 2016-06-15
STALE3727d

Revision v1 of 4 in this series.

Revisions (4)
  1. v1 current
  2. v2 [diff vs current]
  3. v4 [diff vs current]
  4. v6 [diff vs current]

[PATCH 17/18] Place the open() call inside the do{} struct and prevent failing close

From: Célestin Matte <hidden>
Date: 2016-06-15 22:57:34
Subsystem: the rest · Maintainer: Linus Torvalds

Placing the open() call inside the do{} struct will automatically close the
filehandle if possible.
Placing the close() call outside the do{} struct is useless and will make it
fail systematically
Change the error message to state that what fails is a fork(), not a file
opening.
Use autodie to properly exit when a print or open call fails.

Signed-off-by: Célestin Matte <redacted>
Signed-off-by: Matthieu Moy <redacted>
---
 contrib/mw-to-git/git-remote-mediawiki.perl |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index 952ddcc..20ddccb 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -23,6 +23,7 @@ binmode STDOUT, ':encoding(UTF-8)';
 
 use URI::Escape;
 use Readonly;
+use autodie;
 
 # Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced
 Readonly my $SLASH_REPLACEMENT => '%2F';
@@ -363,8 +364,6 @@ sub run_git {
 		local $/ = undef;
 		<$git>
 	};
-	close($git);
-
 	return $res;
 }
 
-- 
1.7.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help