Re: The great alpha compile warning hunt

Sean Hunter (sean@uncarved.co.uk)
Fri, 23 Jul 1999 08:21:08 +0100


Thanks very much for all the helpful comments. I have sent my first
patch to the coda maintainers, and will be sending one to the raid
maintainers and one to the nfs guys.

I found that, since the "%Zd" etc type arguments to printk (for
printing size_t args) are not supported, I was usually casting to long
and doing printk "%ld", which I think works everywhere. Would a patch
to printk to accept "%Zd" etc be worthwhile?

There were a couple of instances where the coda guys were doing printk
"%*s", and passing a size_t as the string length specifier. I have
cast these to int, because you can't have a long as a string length
specifier, and I assume that the string length is going to be short
anyway (otherwise it would fill the log, right?)

A lot of the other warnings were caused by casting pointers into
ints. I have squashed some of these, but need to post to verify the
correctness of a couple of other changes (later.).

In the meantime, here's the first patch, which I sent to the coda
maintainers. Please test and flame as appropriate.

DISCLAIMER: My coda server is down at present, so I can't verify the
correctness of this too rigorously. Having said that, all the changes
are in printk's, so the worst it could do is print garbage in your
logs.

Sean "One patch" Hunter

BTW, please note that I cc'd the wrong address for Richard Henderson in
the original of this.

diff -ur linux.vanilla/fs/coda/cnode.c linux/fs/coda/cnode.c
--- linux.vanilla/fs/coda/cnode.c Mon Jan 25 18:28:35 1999
+++ linux/fs/coda/cnode.c Fri Jul 23 08:36:46 1999
@@ -103,10 +103,10 @@
if ( coda_f2i(fid) != ino ) {
if ( !coda_fid_is_weird(fid) )
printk("Coda: unknown weird fid: ino %ld, fid %s."
- "Tell Peter.\n", ino, coda_f2s(&cnp->c_fid));
+ "Tell Peter.\n", (long)ino, coda_f2s(&cnp->c_fid));
list_add(&cnp->c_volrootlist, &sbi->sbi_volroothead);
CDEBUG(D_UPCALL, "Added %ld ,%s to volroothead\n",
- ino, coda_f2s(&cnp->c_fid));
+ (long)ino, coda_f2s(&cnp->c_fid));
}

coda_fill_inode(*inode, &attr);
@@ -202,7 +202,7 @@
inode = iget(sb, nr);
if ( !inode ) {
printk("coda_fid_to_inode: null from iget, sb %p, nr %ld.\n",
- sb, nr);
+ sb, (long)nr);
return NULL;
}

diff -ur linux.vanilla/fs/coda/dir.c linux/fs/coda/dir.c
--- linux.vanilla/fs/coda/dir.c Wed Jul 21 12:05:38 1999
+++ linux/fs/coda/dir.c Fri Jul 23 08:41:36 1999
@@ -124,12 +124,12 @@

if ( length > CODA_MAXNAMLEN ) {
printk("name too long: lookup, %s (%*s)\n",
- coda_f2s(&dircnp->c_fid), length, name);
+ coda_f2s(&dircnp->c_fid), (int)length, name);
return ERR_PTR(-ENAMETOOLONG);
}

- CDEBUG(D_INODE, "name %s, len %d in ino %ld, fid %s\n",
- name, length, dir->i_ino, coda_f2s(&dircnp->c_fid));
+ CDEBUG(D_INODE, "name %s, len %ld in ino %ld, fid %s\n",
+ name, (long)length, dir->i_ino, coda_f2s(&dircnp->c_fid));

/* control object, create inode on the fly */
if (coda_isroot(dir) && coda_iscontrol(name, length)) {
@@ -156,7 +156,7 @@
return ERR_PTR(error);
} else if (error != -ENOENT) {
CDEBUG(D_INODE, "error for %s(%*s)%d\n",
- coda_f2s(&dircnp->c_fid), length, name, error);
+ coda_f2s(&dircnp->c_fid), (int)length, name, error);
return ERR_PTR(error);
}
CDEBUG(D_INODE, "lookup: %s is (%s), type %d result %d, dropme %d\n",
@@ -503,10 +503,10 @@
old_cnp = ITOC(old_dir);
new_cnp = ITOC(new_dir);

- CDEBUG(D_INODE, "old: %s, (%d length, %d strlen), new: %s"
- "(%d length, %d strlen).old:d_count: %d, new:d_count: %d\n",
- old_name, old_length, strlen(old_name), new_name, new_length,
- strlen(new_name),old_dentry->d_count, new_dentry->d_count);
+ CDEBUG(D_INODE, "old: %s, (%d length, %ld strlen), new: %s"
+ "(%d length, %ld strlen).old:d_count: %d, new:d_count: %d\n",
+ old_name, old_length, (long)strlen(old_name), new_name, new_length,
+ (long)strlen(new_name),old_dentry->d_count, new_dentry->d_count);

/* the C library will do unlink/create etc */
if ( coda_crossvol_rename == 0 &&
@@ -593,12 +593,12 @@
error = venus_open(i->i_sb, &(cnp->c_fid), coda_flags, &ino, &dev);
if (error) {
CDEBUG(D_FILE, "venus: dev %d, inode %ld, out->result %d\n",
- dev, ino, error);
+ dev, (long)ino, error);
return error;
}

/* coda_upcall returns ino number of cached object, get inode */
- CDEBUG(D_FILE, "cache file dev %d, ino %ld\n", dev, ino);
+ CDEBUG(D_FILE, "cache file dev %d, ino %ld\n", dev, (long)ino);
error = coda_inode_grab(dev, ino, &cont_inode);

if ( error || !cont_inode ){
@@ -621,9 +621,9 @@

CDEBUG(D_FILE, "result %d, coda i->i_count is %d for ino %ld\n",
error, i->i_count, i->i_ino);
- CDEBUG(D_FILE, "cache ino: %ld, count %d, ops %x\n",
+ CDEBUG(D_FILE, "cache ino: %ld, count %d, ops %p\n",
cnp->c_ovp->i_ino, cnp->c_ovp->i_count,
- (int)(cnp->c_ovp->i_op));
+ (cnp->c_ovp->i_op));
EXIT;
return 0;
}
diff -ur linux.vanilla/fs/coda/file.c linux/fs/coda/file.c
--- linux.vanilla/fs/coda/file.c Mon Aug 31 23:46:10 1998
+++ linux/fs/coda/file.c Fri Jul 23 08:44:41 1999
@@ -155,8 +155,8 @@
result = cont_file.f_op->read(&cont_file , buff, count,
&(cont_file.f_pos));

- CDEBUG(D_FILE, "ops at %x result %d, count %d, position: %d\n",
- (int)cont_file.f_op, result, count, (int)cont_file.f_pos);
+ CDEBUG(D_FILE, "ops at %p result %d, count %ld, position: %d\n",
+ cont_file.f_op, result, (long)count, (int)cont_file.f_pos);

coda_restore_codafile(coda_inode, coda_file, cont_inode, &cont_file);
return result;
@@ -292,10 +292,10 @@

if ( *ind == NULL ) {
printk("coda_inode_grab: iget(dev: %d, ino: %ld)
- returns NULL.\n", dev, ino);
+ returns NULL.\n", dev, (long)ino);
return -ENOENT;
}
- CDEBUG(D_FILE, "ino: %ld, ops at %x\n", ino, (int)(*ind)->i_op);
+ CDEBUG(D_FILE, "ino: %ld, ops at %p\n", (long)ino, (*ind)->i_op);
return 0;
}

diff -ur linux.vanilla/fs/coda/psdev.c linux/fs/coda/psdev.c
--- linux.vanilla/fs/coda/psdev.c Wed Jul 21 12:05:46 1999
+++ linux/fs/coda/psdev.c Fri Jul 23 08:39:11 1999
@@ -98,8 +98,8 @@
if (copy_from_user(&hdr, buf, 2 * sizeof(u_long)))
return -EFAULT;

- CDEBUG(D_PSDEV, "(process,opc,uniq)=(%d,%ld,%ld), count %d\n",
- current->pid, hdr.opcode, hdr.unique, count);
+ CDEBUG(D_PSDEV, "(process,opc,uniq)=(%d,%ld,%ld), count %ld\n",
+ current->pid, hdr.opcode, hdr.unique, (long)count);

if (DOWNCALL(hdr.opcode)) {
struct super_block *sb = NULL;
@@ -160,8 +160,8 @@

/* move data into response buffer. */
if (req->uc_outSize < count) {
- printk("psdev_write: too much cnt: %d, cnt: %d, opc: %ld, uniq: %ld.\n",
- req->uc_outSize, count, hdr.opcode, hdr.unique);
+ printk("psdev_write: too much cnt: %d, cnt: %ld, opc: %ld, uniq: %ld.\n",
+ req->uc_outSize, (long)count, hdr.opcode, hdr.unique);
count = req->uc_outSize; /* don't have more space! */
}
if (copy_from_user(req->uc_data, buf, count))
@@ -172,8 +172,8 @@
req->uc_flags |= REQ_WRITE;

CDEBUG(D_PSDEV,
- "Found! Count %d for (opc,uniq)=(%ld,%ld), upc_req at %x\n",
- count, hdr.opcode, hdr.unique, (int)&req);
+ "Found! Count %ld for (opc,uniq)=(%ld,%ld), upc_req at %p\n",
+ (long)count, hdr.opcode, hdr.unique, &req);

wake_up(&req->uc_sleep);
return(count);
@@ -190,7 +190,7 @@
struct upc_req *req;
int result = count ;

- CDEBUG(D_PSDEV, "count %d\n", count);
+ CDEBUG(D_PSDEV, "count %ld\n", (long)count);
if (list_empty(&(vcp->vc_pending))) {
return -1;
}
@@ -203,8 +203,8 @@
result = req->uc_inSize;

if (count < req->uc_inSize) {
- printk ("psdev_read: Venus read %d bytes of %d in message\n",
- count, req->uc_inSize);
+ printk ("psdev_read: Venus read %ld bytes of %d in message\n",
+ (long)count, req->uc_inSize);
}

if ( copy_to_user(buf, req->uc_data, result))
diff -ur linux.vanilla/fs/coda/upcall.c linux/fs/coda/upcall.c
--- linux.vanilla/fs/coda/upcall.c Wed Jul 21 12:05:34 1999
+++ linux/fs/coda/upcall.c Fri Jul 23 08:47:29 1999
@@ -670,8 +670,8 @@
/* Append msg to pending queue and poke Venus. */
list_add(&(req->uc_chain), vcommp->vc_pending.prev);
CDEBUG(D_UPCALL,
- "Proc %d wake Venus for(opc,uniq) =(%d,%d) msg at %x.zzz.\n",
- current->pid, req->uc_opcode, req->uc_unique, (int)req);
+ "Proc %d wake Venus for(opc,uniq) =(%d,%d) msg at %p.zzz.\n",
+ current->pid, req->uc_opcode, req->uc_unique, req);

wake_up_interruptible(&vcommp->vc_waitq);
/* We can be interrupted while we wait for Venus to process
@@ -691,8 +691,8 @@
req->uc_opcode, jiffies - req->uc_posttime,
req->uc_unique, req->uc_outSize);
CDEBUG(D_UPCALL,
- "..process %d woken up by Venus for req at 0x%x, data at %x\n",
- current->pid, (int)req, (int)req->uc_data);
+ "..process %d woken up by Venus for req at 0x%p, data at %p\n",
+ current->pid, req, req->uc_data);
if (vcommp->vc_pid) { /* i.e. Venus is still alive */
/* Op went through, interrupt or not... */
if (req->uc_flags & REQ_WRITE) {
diff -ur linux.vanilla/include/linux/coda_linux.h linux/include/linux/coda_linux.h
--- linux.vanilla/include/linux/coda_linux.h Thu Jul 22 17:24:42 1999
+++ linux/include/linux/coda_linux.h Fri Jul 23 08:36:46 1999
@@ -113,10 +113,10 @@
do { \
if (size < 3000) { \
ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \
- CDEBUG(D_MALLOC, "kmalloced: %x at %x.\n", (int) size, (int) ptr);\
+ CDEBUG(D_MALLOC, "kmalloced: %lx at %p.\n", (long)size, ptr);\
} else { \
ptr = (cast)vmalloc((unsigned long) size); \
- CDEBUG(D_MALLOC, "vmalloced: %x at %x.\n", (int) size, (int) ptr);}\
+ CDEBUG(D_MALLOC, "vmalloced: %lx at %p .\n", (long)size, ptr);}\
if (ptr == 0) { \
printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
} \
@@ -124,7 +124,7 @@
} while (0)


-#define CODA_FREE(ptr,size) do {if (size < 3000) { kfree_s((ptr), (size)); CDEBUG(D_MALLOC, "kfreed: %x at %x.\n", (int) size, (int) ptr); } else { vfree((ptr)); CDEBUG(D_MALLOC, "vfreed: %x at %x.\n", (int) size, (int) ptr);} } while (0)
+#define CODA_FREE(ptr,size) do {if (size < 3000) { kfree_s((ptr), (size)); CDEBUG(D_MALLOC, "kfreed: %lx at %p.\n", (long) size, ptr); } else { vfree((ptr)); CDEBUG(D_MALLOC, "vfreed: %lx at %p.\n", (long) size, ptr);} } while (0)

/* inode to cnode */

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/