[PATCH] fix undefined C behaviour in jfs_logform

Christoph Hellwig <[email protected]> Fri, 9 Aug 2002 18:45:37 +0100
Newsgroups gmane.comp.file-systems.jfs.patches
Message-ID <[email protected]>
referencing a variable before assigning a value to it is never a good
idea..


2002-08-10  Christoph Hellwig  <[email protected]>

	* libfs/logform.c (jfs_logform): Calculate log_begin earlier.


Index: libfs/logform.c
===================================================================
RCS file: /usr/cvs/jfs/jfsutils/libfs/logform.c,v
retrieving revision 1.12
diff -u -p -r1.12 logform.c
--- libfs/logform.c	12 Jul 2002 21:55:53 -0000	1.12
+++ libfs/logform.c	9 Aug 2002 17:14:34 -0000
@@ -71,6 +71,10 @@ int jfs_logform(int fd,		/* this is a fi
 	int Working_counter;
 	char *Working[5];
 
+	/* find the log superblock location 
+	 */
+	log_begin = log_start << s_l2bsize;
+
 #define LOGBUFSIZE	4 * LOGPSIZE
 	logp = (logpage_t *) & logpages;
 	Working[0] = "   |\r";
@@ -140,10 +144,6 @@ int jfs_logform(int fd,		/* this is a fi
 
 	for (k = 0; k < MAX_ACTIVE; k++)
 		uuid_clear(log_sup.active[k]);
-
-	/* find the log superblock location 
-	 */
-	log_begin = log_start << s_l2bsize;
 
 	/* swap if on big endian machine */
 	ujfs_swap_logsuper_t(&log_sup);
Index: libfs/logredo.h