Skip to contentSkip to conversation

fixing compile warnings

KJ David Farning 2 participants 2 messages Sep 11, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

I am working my way through the compile warnings in /fs

I have come across this set of warning

fs/jfs/jfs_txnmgr.c: In function ‘txCommit’:
fs/jfs/jfs_txnmgr.c:1922: warning: ‘pxd.addr2’ may be used uninitialized in this function
fs/jfs/jfs_txnmgr.c:1922: warning: ‘pxd.addr1’ may be used uninitialized in this function
fs/jfs/jfs_txnmgr.c:1922: warning: ‘pxd.len’ may be used uninitialized in this function

The relevant code is as follows

	if (tlck->type & tlckTRUNCATE) {
		pxd_t pxd;	/* truncated extent of xad */
		int twm;

pxd_t is defined as follows

96 typedef struct {

 97         unsigned len:24;
 98         unsigned addr1:8;
 99         __le32 addr2;

100 } pxd_t;

What is the proper (kernel) way to initialize pxd_t in jfs_txnmgr.c to silence the warnings?

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw
Quoted 11 lines · David Farning

I am working my way through the compile warnings in /fs

I have come across this set of warning

fs/jfs/jfs_txnmgr.c: In function ???txCommit???:
fs/jfs/jfs_txnmgr.c:1922: warning: ???pxd.addr2??? may be used uninitialized in this function
fs/jfs/jfs_txnmgr.c:1922: warning: ???pxd.addr1??? may be used uninitialized in this function
fs/jfs/jfs_txnmgr.c:1922: warning: ???pxd.len??? may be used uninitialized in this function

If I read xtLog() correctly there is no way pxd can be used with out being initialised.

The code goes something like:
xtLog()
{
...

	if (tlck->type & tlckTRUNCATE) {
		pxd_t pxd;	/* truncated extent of xad */
		....
		if (twm = next - 1) {
			...
			pxd = pxdlock->pxd;	/* save to format maplock */
			...
		}
		...
		if (twm = next - 1) {
			...
			pxdlock->pxd = pxd;
			...
		}
	}

...
}

With no changes to twm or next between the 2 access.

Quoted 2 lines

What is the proper (kernel) way to initialize pxd_t in jfs_txnmgr.c to silence the warnings?

I guess you could do something like:

---

        if (tlck->type & tlckTRUNCATE) {
-               pxd_t pxd;      /* truncated extent of xad */
+               /* truncated extent of xad */
+               pxd_t pxd = {0, 0, 0};  /* FIXME: shutup GCC */
                int twm;

---

But I don't really think that's acceptable.

However, in looking at this question I found a shadow variable, I think the patch below is a reasonable fix.

From: Tony Breeds <[email protected]>

Remove shadow variable from fs/jfs/jfs_txnmgr.c:xtLog()

---

 fs/jfs/jfs_txnmgr.c |    2 --

---

fs/jfs/jfs_txnmgr.c +0 -2
@@ -2026,8 +2026,6 @@ static void xtLog(struct jfs_log * log, 
                 * truncate entry XAD[twm = next - 1]:
                 */
                if (twm = next - 1) {
-                       struct pxd_lock *pxdlock;
-
                        /* format a maplock for txUpdateMap() to update bmap
                         * to free truncated delta extent of the truncated
                         * entry XAD[next - 1];

---

Yours Tony

linux.conf.au http://linux.conf.au/ || http://lca2007.linux.org.au/
Jan 15-20 2007 The Australian Linux Technical Conference!

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors