On Tuesday 21 October 2008 10:20:24 Mike Frysinger wrote:
> On Tuesday 21 October 2008, CAI Qian wrote:
> > Hi,
> >
> > I have one concern about this part,
> >
> > diff --git a/testcases/network/iptables/iptables_tests.sh
> >  b/testcases/network/iptables/iptables_tests.sh

... snipped part of a patch removing the use of "local" keyword ...

> >
> > As all "local" keywords has been removed, is it possible that those
> > variable have been reused unexpectedly later? Otherwise, all those
> > patches look good, and seems not break any existing functionality.
>
> did you actually hit an issue with the usage of "local" ?  while it isnt in
> POSIX, there has yet to be anyone to use a real shell that doesnt support
> it. considering the bugs it prevents, it should stay if you dont have a
> real case.

The issue I was solving when making this patch was checkbashisms 
(http://packages.debian.org/sid/devscripts) complaining about it, so I had to 
patch it to get rid of lintian warnings. I've checked that

 - the variables are always initialised before use in the testXX functions
 - the testXX functions don't recurse nor call each other
 - the variables are not used outside testXX functions

so IIUC, the transformation should be safe. However, if you're seriously 
worried about it, you can reintroduce the locals by applying the attached 
patch, it wouldn't matter to me.

Regards
    Jiri Palecek

? reintroduce-locals.patch
Index: testcases/network/iptables/iptables_tests.sh
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/network/iptables/iptables_tests.sh,v
retrieving revision 1.4
diff -u -r1.4 iptables_tests.sh
--- testcases/network/iptables/iptables_tests.sh	21 Oct 2008 06:54:15 -0000	1.4
+++ testcases/network/iptables/iptables_tests.sh	21 Oct 2008 09:18:50 -0000
@@ -134,9 +134,9 @@
 	TCID=iptables01		# Name of the test case.
 	TST_COUNT=1		# Test number.
 
-	chaincnt=0	# chain counter
+	local chaincnt=0	# chain counter
 
-	cmd="iptables -L -t filter"
+	local cmd="iptables -L -t filter"
 	tst_resm TINFO \
 		"$TCID: $cmd will list all rules in table filter."
 	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
@@ -155,7 +155,7 @@
 		fi
 	fi
 
-	cmd="iptables -L -t nat"
+	local cmd="iptables -L -t nat"
 	tst_resm TINFO \
 		"$TCID: $cmd will list all rules in table nat."
 	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
@@ -174,7 +174,7 @@
 		fi
 	fi
 
-	cmd="iptables -L -t mangle" 
+	local cmd="iptables -L -t mangle" 
 	tst_resm TINFO \
 		"$TCID: $cmd will list all rules in table mangle."
 	$cmd > $LTPTMP/tst_iptables.out 2>&1 || RC=$?
@@ -351,8 +351,8 @@
 	RC=0			# Return value from commands.
 	TCID=iptables04		# Name of the test case.
 	TST_COUNT=4		# Test number.
-	dport=45886				# destination port
-	logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
+	local dport=45886				# destination port
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
 
 	tst_resm TINFO \
 		"$TCID: Use iptables to log packets to particular port."
@@ -417,8 +417,8 @@
 	RC=0			# Return value from commands.
 	TCID=iptables05		# Name of the test case.
 	TST_COUNT=5		# Test number.
-	dport=0					# destination port
-	logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
+	local dport=0					# destination port
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
 
 	tst_resm TINFO \
 		"$TCID: Use iptables to log packets to multiple ports."
@@ -492,8 +492,8 @@
 	RC=0			# Return value from commands.
 	TCID=iptables06		# Name of the test case.
 	TST_COUNT=6		# Test number.
-	logcnt=0		# log counter
-	logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
+	local logcnt=0		# log counter
+	local logprefix="$TCID-$(date +%m%d%H%M%S):"	# log-prefix used by iptables
 
 	tst_resm TINFO \
 		"$TCID: Use iptables to log ping request with limited rate."
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to