Skip to contentSkip to conversation

tst_res: save errno at the begin, otherwise it may be rewritten

PATCH In review Andrew Vagin 3 participants 3 messages Nov 25, 2009 – Dec 1, 2009 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tst_res: save errno at the begin, otherwise it may be rewritten

it may do fprinf for example.

---
 lib/tst_res.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
lib/tst_res.c +2 -3
index ded3cd6..75fe263 100644
@@ -457,6 +457,7 @@ void tst_flush(void)
  */
 static void tst_print(char *tcid, int tnum, int trange, int ttype, char *tmesg)
 {
+	int err = errno; /* avoid unintended side effects */
 	const char *type;
 	int ttype_result = TTYPE_RESULT(ttype);
 
@@ -499,11 +500,9 @@ static void tst_print(char *tcid, int tnum, int trange, int ttype, char *tmesg)
 			fprintf(T_out, "%-8s %4d       %s  :  %s",
 				tcid, tnum, type, tmesg);
 	}
-	if (ttype & TERRNO) {
-		int err = errno; /* avoid unintended side effects */
+	if (ttype & TERRNO)
 		fprintf(T_out, ": errno=%s(%i): %s", strerrnodef(err),
 			err, strerror(err));
-	}
 	if (ttype & TTERRNO)
 		fprintf(T_out, ": TEST_ERRNO=%s(%i): %s", strerrnodef(TEST_ERRNO),
 			(int)TEST_ERRNO, strerror(TEST_ERRNO));
Signature · 12 lines
1.6.2.5


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw
Quoted 1 line · On Wednesday 25 November 2009 08:36:35 Andrew Vagin wrote:

it may do fprinf for example.

it seems a little paranoid, but i dont see any harm in the change -mike

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
Quoted 4 lines · Mike Frysinger
Quoted 1 line · On Wednesday 25 November 2009 08:36:35 Andrew Vagin wrote:

it may do fprinf for example.

it seems a little paranoid, but i dont see any harm in the change

Committed -- thanks!
-Garrett

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list