From 183f3f9b00960a19baf5b7f4b504fc4b9ac3ed96 Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Sun, 25 Apr 2010 12:53:37 +0000 Subject: [PATCH] Fix dead variable assignment, spotted by clang analyzer Fix clang warnings: ../kernel/dict.c:289:2: warning: Value stored to 'len' is never read len -= sizeof(dictionary_header_t); ../packages/cmdline.c:181:8: warning: Value stored to 'buf' during its initialization is never read char *buf = ci->buf; ../libopenbios/elf_info.c:126:2: warning: Value stored to 'name' is never read name = addr; ../libopenbios/elf_load.c:277:5: warning: Value stored to 'addr' is never read addr += pad; ../drivers/ide.c:209:3: warning: Value stored to 'err' is never read err = ob_ide_pio_readb(drive, IDEREG_ERROR); ../drivers/ide.c:219:17: warning: Value stored to 'old_cdb' during its initialization is never read unsigned char old_cdb = cmd->cdb[0]; ../drivers/ide.c:222:4: warning: Value stored to 'old_cdb' is never read old_cdb = cmd->old_cdb; ../drivers/pci.c:103:2: warning: Value stored to 'ss' is never read ss = 0; ../drivers/pci.c:100:2: warning: Value stored to 'dev' is never read dev = 0; ../drivers/pci.c:212:2: warning: Value stored to 'bus' is never read bus = (hi >> 16) & 0xFF; ../drivers/pci.c:953:4: warning: Value stored to 'rev' is never read rev = pci_config_read8(addr, PCI_REVISION_ID); ../packages/video.c:331:2: warning: Value stored to 's' is never read s = video.fb.mphys - s; ../packages/video.c:330:2: warning: Value stored to 'size' is never read size = ((video.fb.h * video.fb.rb + s) + 0xfff) & ~0xfff; ../fs/hfsplus/btree.c:229:5: warning: Value stored to 'p' is never read p = btree_readhead(&bt->head, p); ../fs/hfsplus/volume.c:149:2: warning: Value stored to 'p' is never read p = volume_readfork(p, &vh->start_file ); Signed-off-by: Blue Swirl git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@751 f158a5a8-5612-0410-a976-696ce0be7e32 --- drivers/ide.c | 9 ++++++++- drivers/pci.c | 8 ++------ fs/hfsplus/btree.c | 2 +- fs/hfsplus/volume.c | 2 +- kernel/dict.c | 1 - libopenbios/elf_info.c | 3 +-- libopenbios/elf_load.c | 1 - packages/cmdline.c | 2 +- packages/video.c | 12 +++++++----- 9 files changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/ide.c b/drivers/ide.c index 3b3fd90..9ff420b 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -196,8 +196,10 @@ ob_ide_400ns_delay(struct ide_drive *drive) static void ob_ide_error(struct ide_drive *drive, unsigned char stat, const char *msg) { +#ifdef CONFIG_DEBUG_IDE struct ide_channel *chan = drive->channel; unsigned char err; +#endif if (!stat) stat = ob_ide_pio_readb(drive, IDEREG_STATUS); @@ -206,11 +208,15 @@ ob_ide_error(struct ide_drive *drive, unsigned char stat, const char *msg) IDE_DPRINTF(" cmd=%x, stat=%x", chan->ata_cmd.command, stat); if ((stat & (BUSY_STAT | ERR_STAT)) == ERR_STAT) { - err = ob_ide_pio_readb(drive, IDEREG_ERROR); +#ifdef CONFIG_DEBUG_IDE + err = +#endif + ob_ide_pio_readb(drive, IDEREG_ERROR); IDE_DPRINTF(", err=%x", err); } IDE_DPRINTF("\n"); +#ifdef CONFIG_DEBUG_IDE /* * see if sense is valid and dump that */ @@ -237,6 +243,7 @@ ob_ide_error(struct ide_drive *drive, unsigned char stat, const char *msg) IDE_DPRINTF(", no sense"); IDE_DPRINTF("\n"); } +#endif } /* diff --git a/drivers/pci.c b/drivers/pci.c index a5b16a6..dbc24e1 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -97,10 +97,8 @@ ob_pci_decode_unit(int *idx) int bus = 0; /* no information */ char *ptr; - dev = 0; fn = 0; reg = 0; - ss = 0; n = 0; p = 0; t = 0; @@ -202,14 +200,13 @@ ob_pci_encode_unit(int *idx) cell hi = POP(); cell mid = POP(); cell lo = POP(); - int n, p, t, ss, bus, dev, fn, reg; + int n, p, t, ss, dev, fn, reg; n = hi & IS_NOT_RELOCATABLE; p = hi & IS_PREFETCHABLE; t = hi & IS_ALIASED; ss = (hi >> 24) & 0x03; - bus = (hi >> 16) & 0xFF; dev = (hi >> 11) & 0x1F; fn = (hi >> 8) & 0x07; reg = hi & 0xFF; @@ -928,7 +925,7 @@ static void ob_scan_pci_bus(int bus, unsigned long *mem_base, pci_config_t config; const pci_dev_t *pci_dev; uint32_t ccode; - uint8_t class, subclass, iface, rev; + uint8_t class, subclass, iface; int num_bars, rom_bar; activate_device("/"); @@ -950,7 +947,6 @@ static void ob_scan_pci_bus(int bus, unsigned long *mem_base, class = ccode >> 8; subclass = ccode; iface = pci_config_read8(addr, PCI_CLASS_PROG); - rev = pci_config_read8(addr, PCI_REVISION_ID); pci_dev = pci_find_device(class, subclass, iface, vid, did); diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c index 48bda41..5409418 100644 --- a/fs/hfsplus/btree.c +++ b/fs/hfsplus/btree.c @@ -226,7 +226,7 @@ static int btree_init(btree* bt, volume* vol, hfsp_fork_raw* fork) p = btree_readnode(&node, p); if (node.kind != HFSP_NODE_HEAD) return -1; // should not happen ? - p = btree_readhead(&bt->head, p); + btree_readhead(&bt->head, p); node_size = bt->head.node_size; bt->blkpernode = node_size / vol->blksize; diff --git a/fs/hfsplus/volume.c b/fs/hfsplus/volume.c index 25a6b4d..3ab2eda 100644 --- a/fs/hfsplus/volume.c +++ b/fs/hfsplus/volume.c @@ -146,7 +146,7 @@ volume_readbuf(hfsp_vh* vh, char * p) p = volume_readfork(p, &vh->ext_file ); p = volume_readfork(p, &vh->cat_file ); p = volume_readfork(p, &vh->attr_file ); - p = volume_readfork(p, &vh->start_file ); + volume_readfork(p, &vh->start_file ); return 0; fail: return -1; diff --git a/kernel/dict.c b/kernel/dict.c index 16e5f82..0986cb1 100644 --- a/kernel/dict.c +++ b/kernel/dict.c @@ -286,7 +286,6 @@ ucell load_dictionary(const char *data, ucell len) } data += sizeof(dictionary_header_t); - len -= sizeof(dictionary_header_t); dicthead = target_long(header->length); diff --git a/libopenbios/elf_info.c b/libopenbios/elf_info.c index e829c2f..f7febef 100644 --- a/libopenbios/elf_info.c +++ b/libopenbios/elf_info.c @@ -103,7 +103,7 @@ void collect_elfboot_info(struct sys_info *info) Elf_Bhdr *hdr = NULL; char *addr, *end; Elf_Nhdr *nhdr; - char *name, *desc; + char *desc; if (info->boot_type == ELF_BHDR_MAGIC) hdr = phys_to_virt(info->boot_data); @@ -123,7 +123,6 @@ void collect_elfboot_info(struct sys_info *info) while (addr < end) { nhdr = (Elf_Nhdr *) addr; addr += sizeof(Elf_Nhdr); - name = addr; addr += (nhdr->n_namesz + 3) & ~3; desc = addr; addr += (nhdr->n_descsz + 3) & ~3; diff --git a/libopenbios/elf_load.c b/libopenbios/elf_load.c index 2f136e7..327693b 100644 --- a/libopenbios/elf_load.c +++ b/libopenbios/elf_load.c @@ -274,7 +274,6 @@ static Elf_Bhdr *add_boot_note(Elf_Bhdr *bhdr, const char *name, addr += nhdr.n_descsz; pad = padded(nhdr.n_descsz) - nhdr.n_descsz; memset(addr, 0, pad); - addr += pad; bhdr->b_size += ent_size; bhdr->b_records++; diff --git a/packages/cmdline.c b/packages/cmdline.c index 8d8ce73..9dc4377 100644 --- a/packages/cmdline.c +++ b/packages/cmdline.c @@ -178,7 +178,7 @@ static void /* ( -- ) */ cmdline_prompt( cmdline_info_t *ci ) { int cur_added=0, histind=0, ch, i, pos=0, n=0, prompt=1; - char *buf = ci->buf; + char *buf; int terminate = 0; buf = ci->buf; diff --git a/packages/video.c b/packages/video.c index 63b7def..be4d6a6 100644 --- a/packages/video.c +++ b/packages/video.c @@ -308,7 +308,10 @@ NODE_METHODS( video ) = { void init_video( unsigned long fb, int width, int height, int depth, int rb ) { - int i, s, size; + int i; +#ifdef CONFIG_PPC + int s, size; +#endif phandle_t ph=0; video.fb.mphys = fb; @@ -326,11 +329,10 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) video.has_video = 1; video.pal = malloc( 256 * sizeof(ulong) ); - s = (video.fb.mphys & 0xfff); - size = ((video.fb.h * video.fb.rb + s) + 0xfff) & ~0xfff; - s = video.fb.mphys - s; - #ifdef CONFIG_PPC + s = (video.fb.mphys & 0xfff); + size = ((video.fb.h * video.fb.rb + s) + 0xfff) & ~0xfff; + ofmem_claim_phys( video.fb.mphys, size, 0 ); ofmem_claim_virt( video.fb.mphys, size, 0 ); ofmem_map( video.fb.mphys, video.fb.mphys, size, -1 );