From 2d2a1a077df8b4e800b3a7915da1955c2b605927 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Sat, 2 Feb 2013 00:55:35 +0000 Subject: [PATCH] panic: declare as printf-style-checked . and related fixes Change-Id: I5131ac57dc53d8aec8d421a34c5ceea383404d7a --- drivers/ahci/ahci.c | 2 +- drivers/at_wini/at_wini.c | 4 ++-- drivers/dpeth/8390.c | 2 +- include/minix/sysutil.h | 3 ++- kernel/arch/i386/memory.c | 2 +- lib/libddekit/src/panic.c | 2 +- lib/libdevman/generic.c | 4 ++-- lib/libdevman/usb.c | 2 +- lib/libminixfs/cache.c | 2 +- lib/libsys/vm_cache.c | 4 ++-- lib/libusb/usb.c | 4 ++-- lib/libvirtio/virtio.c | 4 ++-- lib/libvtreefs/vtreefs.c | 4 ++-- servers/ext2/balloc.c | 2 +- servers/ext2/ialloc.c | 2 +- servers/ext2/inode.c | 2 +- servers/ext2/link.c | 2 +- servers/ext2/open.c | 2 +- servers/ext2/super.c | 2 +- servers/procfs/tree.c | 2 +- servers/vfs/filedes.c | 2 +- servers/vm/arch/i386/pagetable.c | 4 ++-- 22 files changed, 30 insertions(+), 29 deletions(-) diff --git a/drivers/ahci/ahci.c b/drivers/ahci/ahci.c index 033a76423..b859e1685 100644 --- a/drivers/ahci/ahci.c +++ b/drivers/ahci/ahci.c @@ -2087,7 +2087,7 @@ static void ahci_init(int devind) * the actual total number of ports to the size of the exposed area. */ if (size < AHCI_MEM_BASE_SIZE + AHCI_MEM_PORT_SIZE) - panic("HBA memory size too small: %lu", size); + panic("HBA memory size too small: %u", size); size = MIN(size, AHCI_MEM_BASE_SIZE + AHCI_MEM_PORT_SIZE * NR_PORTS); diff --git a/drivers/at_wini/at_wini.c b/drivers/at_wini/at_wini.c index 0968ddb2e..5108cf6ad 100644 --- a/drivers/at_wini/at_wini.c +++ b/drivers/at_wini/at_wini.c @@ -1536,7 +1536,7 @@ static int setup_dma( if (n > size) n= size; if (n == 0 || (n & 1)) - panic("bad size in iov: %d", iov[i].iov_size); + panic("bad size in iov: 0x%lx", iov[i].iov_size); if(proc_nr != SELF) { r= sys_umap(proc_nr, VM_GRANT, iov[i].iov_addr, n, &user_phys); @@ -1609,7 +1609,7 @@ static int setup_dma( panic("Bus master IDE active"); if (prdt_phys & 3) - panic("prdt not aligned: %d", prdt_phys); + panic("prdt not aligned: 0x%lx", prdt_phys); r= sys_outl(wn->base_dma + DMA_PRDTP, prdt_phys); if (r != 0) panic("setup_dma: sys_outl failed: %d", r); diff --git a/drivers/dpeth/8390.c b/drivers/dpeth/8390.c index 43f81deda..521a34159 100644 --- a/drivers/dpeth/8390.c +++ b/drivers/dpeth/8390.c @@ -273,7 +273,7 @@ static void pio_user2nic(dpeth_t *dep, int pageno, int pktsize) if (inb_reg0(dep, DP_ISR) & ISR_RDC) break; } if (ix == 100) { - panic(RdmaErrMsg); + panic("%s", RdmaErrMsg); } return; } diff --git a/include/minix/sysutil.h b/include/minix/sysutil.h index 102ff5758..c676277c9 100644 --- a/include/minix/sysutil.h +++ b/include/minix/sysutil.h @@ -48,7 +48,8 @@ int fkey_ctl(int req, int *fkeys, int *sfkeys); int printf(const char *fmt, ...); void kputc(int c); -__dead void panic(const char *fmt, ...); +__dead void panic(const char *fmt, ...) + __attribute__((__format__(__printf__,1,2))); int getuptime(clock_t *ticks, clock_t *realtime, time_t *boottime); int getticks(clock_t *ticks); int tickdelay(clock_t ticks); diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 3eca8bbba..943a26a7a 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -289,7 +289,7 @@ vir_bytes bytes; /* # of bytes to be copied */ phys = 0; } else { if(phys == 0) - panic("vm_lookup returned phys: %d", phys); + panic("vm_lookup returned phys: 0x%lx", phys); } if(phys == 0) { diff --git a/lib/libddekit/src/panic.c b/lib/libddekit/src/panic.c index ad63e3ab5..a3c8e6a1b 100644 --- a/lib/libddekit/src/panic.c +++ b/lib/libddekit/src/panic.c @@ -15,7 +15,7 @@ void ddekit_panic(char *fmt, ...) va_start(va,fmt); r = vprintf(fmt, va); va_end(va); - panic("","",0); + panic("panicced"); while(1) ; diff --git a/lib/libdevman/generic.c b/lib/libdevman/generic.c index ff77cc992..ee79cfc3e 100644 --- a/lib/libdevman/generic.c +++ b/lib/libdevman/generic.c @@ -128,7 +128,7 @@ int devman_add_device(struct devman_dev *dev) } if (msg.DEVMAN_RESULT != 0) { - panic("devman_add_device: could add device: %d", + panic("devman_add_device: could add device: %ld", msg.DEVMAN_RESULT); } @@ -168,7 +168,7 @@ int devman_del_device(struct devman_dev *dev) } if (msg.DEVMAN_RESULT != 0) { - panic("devman_del_device: could delete device: %d", + panic("devman_del_device: could delete device: %ld", msg.DEVMAN_RESULT); } diff --git a/lib/libdevman/usb.c b/lib/libdevman/usb.c index 699f45c48..65d0ff347 100644 --- a/lib/libdevman/usb.c +++ b/lib/libdevman/usb.c @@ -11,7 +11,7 @@ #include "local.h" #define CHECKOUTOFMEM(ptr) if(ptr == NULL) \ - panic("Out of memory! (%s, line %d)" \ + panic("Out of memory! (%s, line %d)", \ __FILE__, __LINE__) diff --git a/lib/libminixfs/cache.c b/lib/libminixfs/cache.c index ad3c6469b..adb482d99 100644 --- a/lib/libminixfs/cache.c +++ b/lib/libminixfs/cache.c @@ -472,7 +472,7 @@ int block_type; /* INODE_BLOCK, DIRECTORY_BLOCK, or whatever */ printf("libminixfs: ENOSYS, disabling VM calls\n"); vmcache = 0; } else { - panic("libminixfs: setblock of 0x%lx dev 0x%x off " + panic("libminixfs: setblock of %p dev 0x%x off " "0x%llx failed\n", bp->data, dev, dev_off); } } diff --git a/lib/libsys/vm_cache.c b/lib/libsys/vm_cache.c index 73883203c..ce844acf0 100644 --- a/lib/libsys/vm_cache.c +++ b/lib/libsys/vm_cache.c @@ -17,11 +17,11 @@ int vm_cachecall(message *m, int call, void *addr, u32_t dev, u64_t dev_offset, blocksize, PAGE_SIZE); if(ino_offset % PAGE_SIZE) - panic("inode offset %d should be a multiple of pagesize %d\n", + panic("inode offset %lld should be a multiple of pagesize %d\n", ino_offset, PAGE_SIZE); if(dev_offset % PAGE_SIZE) - panic("dev offset offset %d should be a multiple of pagesize %d\n", + panic("dev offset offset %lld should be a multiple of pagesize %d\n", dev_offset, PAGE_SIZE); memset(m, 0, sizeof(*m)); diff --git a/lib/libusb/usb.c b/lib/libusb/usb.c index 0b3ffcdaa..be865f891 100644 --- a/lib/libusb/usb.c +++ b/lib/libusb/usb.c @@ -59,7 +59,7 @@ int usb_send_urb(struct usb_urb* urb) } if (msg.USB_RESULT != 0) { - panic("usb_send_urb: hcd could not enqueue URB: %d", msg.USB_RESULT); + panic("usb_send_urb: hcd could not enqueue URB: %ld", msg.USB_RESULT); } /* everything ok, add urb to pending_urbs */ @@ -145,7 +145,7 @@ int usb_init(char *name) } if (msg.USB_RESULT != 0 ) { - panic("usb_init: init failed: %d", msg.USB_RESULT); + panic("usb_init: init failed: %ld", msg.USB_RESULT); } return 0; diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c index 4fb77a6ab..787987083 100644 --- a/lib/libvirtio/virtio.c +++ b/lib/libvirtio/virtio.c @@ -498,7 +498,7 @@ clear_indirect_table(struct virtio_device *dev, struct vring_desc *vd) } if (i >= dev->num_indirect) - panic("%s: Could not clear indirect descriptor table "); + panic("Could not clear indirect descriptor table "); } @@ -538,7 +538,7 @@ set_indirect_descriptors(struct virtio_device *dev, struct virtio_queue *q, /* Sanity check */ if (i >= dev->num_indirect) - panic("%s: No indirect descriptor tables left"); + panic("No indirect descriptor tables left"); /* For indirect descriptor tables, only a single descriptor from * the main ring is used. diff --git a/lib/libvtreefs/vtreefs.c b/lib/libvtreefs/vtreefs.c index 2131d5301..1c69e0868 100644 --- a/lib/libvtreefs/vtreefs.c +++ b/lib/libvtreefs/vtreefs.c @@ -115,7 +115,7 @@ static int get_work(void) int r; if ((r = sef_receive(ANY, &fs_m_in)) != OK) - panic(__FILE__, "receive failed", r); + panic("receive failed: %d", r); return fs_m_in.m_type; } @@ -135,7 +135,7 @@ static void send_reply(int err, int transid) } if ((r = send(fs_m_in.m_source, &fs_m_out)) != OK) - panic(__FILE__, "unable to send reply", r); + panic("unable to send reply: %d", r); } /*===========================================================================* diff --git a/servers/ext2/balloc.c b/servers/ext2/balloc.c index 759220c24..bef14964c 100644 --- a/servers/ext2/balloc.c +++ b/servers/ext2/balloc.c @@ -316,7 +316,7 @@ void free_block(struct super_block *sp, bit_t bit_returned) bp = get_block(sp->s_dev, gd->block_bitmap, NORMAL); if (unsetbit(b_bitmap(bp), bit)) - panic("Tried to free unused block", bit_returned); + panic("Tried to free unused block %d", bit_returned); lmfs_markdirty(bp); put_block(bp, MAP_BLOCK); diff --git a/servers/ext2/ialloc.c b/servers/ext2/ialloc.c index 187733e10..6cb18106d 100644 --- a/servers/ext2/ialloc.c +++ b/servers/ext2/ialloc.c @@ -229,7 +229,7 @@ static void free_inode_bit(struct super_block *sp, bit_t bit_returned, bp = get_block(sp->s_dev, gd->inode_bitmap, NORMAL); if (unsetbit(b_bitmap(bp), bit)) - panic("Tried to free unused inode", bit_returned); + panic("Tried to free unused inode %d", bit_returned); lmfs_markdirty(bp); put_block(bp, MAP_BLOCK); diff --git a/servers/ext2/inode.c b/servers/ext2/inode.c index 72a228991..45107d94f 100644 --- a/servers/ext2/inode.c +++ b/servers/ext2/inode.c @@ -234,7 +234,7 @@ void put_inode( return; /* checking here is easier than in caller */ if (rip->i_count < 1) - panic("put_inode: i_count already below 1", rip->i_count); + panic("put_inode: i_count already below 1: %d", rip->i_count); if (--rip->i_count == 0) { /* i_count == 0 means no one is using it now */ if (rip->i_links_count == NO_LINK) { diff --git a/servers/ext2/link.c b/servers/ext2/link.c index 939d9e9c0..831099b4c 100644 --- a/servers/ext2/link.c +++ b/servers/ext2/link.c @@ -718,7 +718,7 @@ off_t len; panic("zeroblock_range: no block"); offset = pos % rip->i_sp->s_block_size; if (offset + len > rip->i_sp->s_block_size) - panic("zeroblock_range: len too long", len); + panic("zeroblock_range: len too long: %d", len); memset(b_data(bp) + offset, 0, len); lmfs_markdirty(bp); put_block(bp, FULL_DATA_BLOCK); diff --git a/servers/ext2/open.c b/servers/ext2/open.c index a28567330..1096e09a3 100644 --- a/servers/ext2/open.c +++ b/servers/ext2/open.c @@ -171,7 +171,7 @@ int fs_mkdir() /* It was not possible to enter . or .. probably disk was full - * links counts haven't been touched. */ if (search_dir(ldirp, lastc, NULL, DELETE, IGN_PERM, 0) != OK) - panic("Dir disappeared ", rip->i_num); + panic("Dir disappeared: %d ", rip->i_num); rip->i_links_count--; /* undo the increment done in new_node() */ } rip->i_dirt = IN_DIRTY; /* either way, i_links_count has changed */ diff --git a/servers/ext2/super.c b/servers/ext2/super.c index 4c34af27d..27c455cde 100644 --- a/servers/ext2/super.c +++ b/servers/ext2/super.c @@ -42,7 +42,7 @@ struct super_block *get_super( if (dev == NO_DEV) panic("request for super_block of NO_DEV"); if (superblock->s_dev != dev) - panic("wrong superblock", (int) dev); + panic("wrong superblock: 0x%x", (int) dev); return(superblock); } diff --git a/servers/procfs/tree.c b/servers/procfs/tree.c index 5365ca20c..239bd888d 100644 --- a/servers/procfs/tree.c +++ b/servers/procfs/tree.c @@ -441,7 +441,7 @@ int lookup_hook(struct inode *parent, char *name, * Alternative: pull in only PM's table? */ if ((r = getticks(&now)) != OK) - panic(__FILE__, "unable to get uptime", r); + panic("unable to get uptime: %d", r); if (last_update != now) { update_tables(); diff --git a/servers/vfs/filedes.c b/servers/vfs/filedes.c index 1ccdb8eb9..f0c3de8a9 100644 --- a/servers/vfs/filedes.c +++ b/servers/vfs/filedes.c @@ -673,7 +673,7 @@ struct filp *f; f->filp_mode = FILP_CLOSED; f->filp_count = 0; } else if (f->filp_count < 0) { - panic("VFS: invalid filp count: %d ino %d/%d", f->filp_count, + panic("VFS: invalid filp count: %d ino %d/%u", f->filp_count, vp->v_dev, vp->v_inode_nr); } else { unlock_vnode(f->filp_vno); diff --git a/servers/vm/arch/i386/pagetable.c b/servers/vm/arch/i386/pagetable.c index aa301ef1f..0f6cca9ce 100644 --- a/servers/vm/arch/i386/pagetable.c +++ b/servers/vm/arch/i386/pagetable.c @@ -1147,9 +1147,9 @@ void pt_init(void) kern_mappings[index].flags |= ARCH_VM_PTE_RO; #endif if(addr % VM_PAGE_SIZE) - panic("VM: addr unaligned: %d", addr); + panic("VM: addr unaligned: %lu", addr); if(len % VM_PAGE_SIZE) - panic("VM: len unaligned: %d", len); + panic("VM: len unaligned: %lu", len); vir = offset; if(sys_vmctl_reply_mapping(index, vir) != OK) panic("VM: reply failed");