Skip to contentSkip to conversation

Fix real bugs uncovered by -Wno-uninitialized removal

PATCH New Anton Blanchard 1 participant 3 messages Sep 11, 2004

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

PATCH 1/1 Fix real bugs uncovered by -Wno-uninitialized removal

The removal of -Wno-uninitialized on ppc64 revealed a number of real bugs.

drivers/char/hvcs.c renamed from drivers/char/hvcs.c~realbugs +3 -3
diff -puN drivers/char/hvcs.c~realbugs drivers/char/hvcs.c
@@ -427,7 +427,7 @@ static int hvcs_io(struct hvcs_struct *h
 	struct tty_struct *tty;
 	char buf[HVCS_BUFF_LEN] __ALIGNED__;
 	unsigned long flags;
-	int got;
+	int got = 0;
 	int i;
 
 	spin_lock_irqsave(&hvcsd->lock, flags);
@@ -945,7 +945,7 @@ static int hvcs_enable_device(struct hvc
  */
 struct hvcs_struct *hvcs_get_by_index(int index)
 {
-	struct hvcs_struct *hvcsd;
+	struct hvcs_struct *hvcsd = NULL;
 	unsigned long flags;
 
 	spin_lock(&hvcs_structs_lock);
@@ -1433,7 +1433,7 @@ static int __init hvcs_module_init(void)
 			" as a tty driver failed.\n");
 		hvcs_free_index_list();
 		put_tty_driver(hvcs_tty_driver);
-		return rc;
+		return -EIO;
 	}
 
 	hvcs_pi_buff = kmalloc(PAGE_SIZE, GFP_KERNEL);
drivers/net/ibmveth.c renamed from drivers/net/ibmveth.c~realbugs +5 -2
diff -puN drivers/net/ibmveth.c~realbugs drivers/net/ibmveth.c
@@ -885,13 +885,16 @@ static int __devinit ibmveth_probe(struc
 
 	mac_addr_p = (unsigned char *) vio_get_attribute(dev, VETH_MAC_ADDR, 0);
 	if(!mac_addr_p) {
-		ibmveth_error_printk("Can't find VETH_MAC_ADDR attribute\n");
+		printk(KERN_ERR "(%s:%3.3d) ERROR: Can't find VETH_MAC_ADDR "
+				"attribute\n", __FILE__, __LINE__); 
 		return 0;
 	}
 	
 	mcastFilterSize_p= (unsigned int *) vio_get_attribute(dev, VETH_MCAST_FILTER_SIZE, 0);
 	if(!mcastFilterSize_p) {
-		ibmveth_error_printk("Can't find VETH_MCAST_FILTER_SIZE attribute\n");
+		printk(KERN_ERR "(%s:%3.3d) ERROR: Can't find "
+				"VETH_MCAST_FILTER_SIZE attribute\n",
+				__FILE__, __LINE__); 
 		return 0;
 	}
 	
drivers/pci/hotplug/rpaphp_core.c renamed from drivers/pci/hotplug/rpaphp_core.c~realbugs +1 -1
diff -puN drivers/pci/hotplug/rpaphp_core.c~realbugs drivers/pci/hotplug/rpaphp_core.c
@@ -449,7 +449,7 @@ static int rpaphp_disable_slot(struct pc
 
 static int disable_slot(struct hotplug_slot *hotplug_slot)
 {
-	int retval;
+	int retval = -EINVAL;
 	struct slot *slot = (struct slot *)hotplug_slot->private;
 
 	dbg("%s - Entry: slot[%s]\n", __FUNCTION__, slot->name);
drivers/pci/hotplug/rpaphp_pci.c renamed from drivers/pci/hotplug/rpaphp_pci.c~realbugs +1 -1
diff -puN drivers/pci/hotplug/rpaphp_pci.c~realbugs drivers/pci/hotplug/rpaphp_pci.c
@@ -186,7 +186,7 @@ static struct pci_dev *
 rpaphp_pci_config_slot(struct device_node *dn, struct pci_bus *bus)
 {
 	struct device_node *eads_first_child = dn->child;
-	struct pci_dev *dev;
+	struct pci_dev *dev = NULL;
 	int num;
 	
 	dbg("Enter %s: dn=%s bus=%s\n", __FUNCTION__, dn->full_name, bus->name);
arch/ppc64/kernel/iSeries_pci_reset.c renamed from arch/ppc64/kernel/iSeries_pci_reset.c~realbugs +2 -1
diff -puN arch/ppc64/kernel/iSeries_pci_reset.c~realbugs arch/ppc64/kernel/iSeries_pci_reset.c
@@ -65,7 +65,8 @@ int iSeries_Device_ToggleReset(struct pc
 		AssertDelay = (5 * HZ) / 10;
 	else
 		AssertDelay = (AssertTime * HZ) / 10;
-	if (WaitDelay == 0)
+
+	if (DelayTime == 0)
 		WaitDelay = (30 * HZ) / 10;
 	else
 		WaitDelay = (DelayTime * HZ) / 10;

_

#1 lore raw

PATCH 1/1 Fix spurious warnings uncovered by -Wno-uninitialized removal

Here are fixes for some false positives.

arch/ppc64/kernel/iommu.c renamed from arch/ppc64/kernel/iommu.c~falsepositives +1 -1
diff -puN arch/ppc64/kernel/iommu.c~falsepositives arch/ppc64/kernel/iommu.c
@@ -229,7 +229,7 @@ int iommu_map_sg(struct device *dev, str
 		struct scatterlist *sglist, int nelems,
 		enum dma_data_direction direction)
 {
-	dma_addr_t dma_next, dma_addr;
+	dma_addr_t dma_next = 0, dma_addr;
 	unsigned long flags;
 	struct scatterlist *s, *outs, *segstart;
 	int outcount;
arch/ppc64/kernel/nvram.c renamed from arch/ppc64/kernel/nvram.c~falsepositives +1 -1
diff -puN arch/ppc64/kernel/nvram.c~falsepositives arch/ppc64/kernel/nvram.c
@@ -340,7 +340,7 @@ static int nvram_create_os_partition(voi
 	struct list_head * p;
 	struct nvram_partition * part;
 	struct nvram_partition * new_part = NULL;
-	struct nvram_partition * free_part;
+	struct nvram_partition * free_part = NULL;
 	int seq_init[2] = { 0, 0 };
 	loff_t tmp_index;
 	long size = 0;
arch/ppc64/kernel/sysfs.c renamed from arch/ppc64/kernel/sysfs.c~falsepositives +7 -6
diff -puN arch/ppc64/kernel/sysfs.c~falsepositives arch/ppc64/kernel/sysfs.c
@@ -97,6 +97,13 @@ __setup("smt-snooze-delay=", setup_smt_s
 
 /* PMC stuff */
 
+#ifdef CONFIG_PPC_ISERIES
+void ppc64_enable_pmcs(void)
+{
+	/* XXX Implement for iseries */
+}
+#else
+
 /*
  * Enabling PMCs will slow partition context switch times so we only do
  * it the first time we write to the PMCs.
@@ -104,12 +111,6 @@ __setup("smt-snooze-delay=", setup_smt_s
 
 static DEFINE_PER_CPU(char, pmcs_enabled);
 
-#ifdef CONFIG_PPC_ISERIES
-void ppc64_enable_pmcs(void)
-{
-	/* XXX Implement for iseries */
-}
-#else
 void ppc64_enable_pmcs(void)
 {
 	unsigned long hid0;
arch/ppc64/kernel/pSeries_pci.c renamed from arch/ppc64/kernel/pSeries_pci.c~falsepositives +1 -1
diff -puN arch/ppc64/kernel/pSeries_pci.c~falsepositives arch/ppc64/kernel/pSeries_pci.c
@@ -497,7 +497,7 @@ unsigned long __init find_and_init_phbs(
 	struct pci_controller *phb;
 	unsigned int root_size_cells = 0;
 	unsigned int index;
-	unsigned int *opprop;
+	unsigned int *opprop = NULL;
 	struct device_node *root = of_find_node_by_path("/");
 
 	if (naca->interrupt_controller == IC_OPEN_PIC) {
arch/ppc64/kernel/rtasd.c renamed from arch/ppc64/kernel/rtasd.c~falsepositives +1 -1
diff -puN arch/ppc64/kernel/rtasd.c~falsepositives arch/ppc64/kernel/rtasd.c
@@ -106,7 +106,7 @@ static char *rtas_event_type(int type)
 static void printk_log_rtas(char *buf, int len)
 {
 
-	int i,j,n;
+	int i,j,n = 0;
 	int perline = 16;
 	char buffer[64];
 	char * str = "RTAS event";
arch/ppc64/kernel/setup.c renamed from arch/ppc64/kernel/setup.c~falsepositives +1 -1
diff -puN arch/ppc64/kernel/setup.c~falsepositives arch/ppc64/kernel/setup.c
@@ -598,7 +598,7 @@ static int __init set_preferred_console(
 {
 	struct device_node *prom_stdout;
 	char *name;
-	int offset;
+	int offset = 0;
 
 	/* The user has requested a console so this is already set up. */
 	if (strstr(saved_command_line, "console="))
arch/ppc64/kernel/signal.c renamed from arch/ppc64/kernel/signal.c~falsepositives +1 -1
diff -puN arch/ppc64/kernel/signal.c~falsepositives arch/ppc64/kernel/signal.c
@@ -178,7 +178,7 @@ static long restore_sigcontext(struct pt
 	elf_vrreg_t __user *v_regs;
 #endif
 	unsigned long err = 0;
-	unsigned long save_r13;
+	unsigned long save_r13 = 0;
 	elf_greg_t *gregs = (elf_greg_t *)regs;
 	int i;
 
arch/ppc64/kernel/signal32.c renamed from arch/ppc64/kernel/signal32.c~falsepositives +1 -1
diff -puN arch/ppc64/kernel/signal32.c~falsepositives arch/ppc64/kernel/signal32.c
@@ -189,7 +189,7 @@ static long restore_user_regs(struct pt_
 	elf_greg_t64 *gregs = (elf_greg_t64 *)regs;
 	int i;
 	long err = 0;
-	unsigned int save_r2;
+	unsigned int save_r2 = 0;
 #ifdef CONFIG_ALTIVEC
 	unsigned long msr;
 #endif
arch/ppc64/oprofile/op_model_rs64.c renamed from arch/ppc64/oprofile/op_model_rs64.c~falsepositives +2 -2
diff -puN arch/ppc64/oprofile/op_model_rs64.c~falsepositives arch/ppc64/oprofile/op_model_rs64.c
@@ -21,8 +21,8 @@
 
 static void ctrl_write(unsigned int i, unsigned int val)
 {
-	unsigned int tmp;
-	unsigned long shift, mask;
+	unsigned int tmp = 0;
+	unsigned long shift = 0, mask = 0;
 
 	dbg("ctrl_write %d %x\n", i, val);
 
arch/ppc64/xmon/xmon.c renamed from arch/ppc64/xmon/xmon.c~falsepositives +1 -1
diff -puN arch/ppc64/xmon/xmon.c~falsepositives arch/ppc64/xmon/xmon.c
@@ -2059,7 +2059,7 @@ ppc_inst_dump(unsigned long adr, long co
 {
 	int nr, dotted;
 	unsigned long first_adr;
-	unsigned long inst, last_inst;
+	unsigned long inst, last_inst = 0;
 	unsigned char val[4];
 
 	dotted = 0;
drivers/char/hvsi.c renamed from drivers/char/hvsi.c~falsepositives +1 -1
diff -puN drivers/char/hvsi.c~falsepositives drivers/char/hvsi.c
@@ -1004,7 +1004,7 @@ static int hvsi_write(struct tty_struct 
 {
 	struct hvsi_struct *hp = tty->driver_data;
 	const char *source = buf;
-	char *kbuf;
+	char *kbuf = NULL;
 	unsigned long flags;
 	int total = 0;
 	int origcount = count;
drivers/macintosh/via-pmu.c renamed from drivers/macintosh/via-pmu.c~falsepositives +1 -1
diff -puN drivers/macintosh/via-pmu.c~falsepositives drivers/macintosh/via-pmu.c
@@ -1446,7 +1446,7 @@ static struct adb_request* __pmac
 pmu_sr_intr(struct pt_regs *regs)
 {
 	struct adb_request *req;
-	int bite;
+	int bite = 0;
 
 	if (via[B] & TREQ) {
 		printk(KERN_ERR "PMU: spurious SR intr (%x)\n", via[B]);
#2 lore raw

PATCH 1/1 Fix real bugs uncovered by -Wno-uninitialized removal 2

In reply to Anton Blanchard

Another real bug.

===== drivers/char/hvc_console.c 1.25 vs edited =====

drivers/char/hvc_console.c +1 -1
@@ -801,7 +801,7 @@
 void hvc_console_print(struct console *co, const char *b, unsigned count)
 {
 	char c[16] __ALIGNED__;
-	unsigned i, n = 0;
+	unsigned i = 0, n = 0;
 	int r, donecr = 0;
 
 	/* Console access attempt outside of acceptable console range. */