Bug 16022 - binutils-2.23.2/bfd/elf32-rx.c:3142: bad switch statement ?
Summary: binutils-2.23.2/bfd/elf32-rx.c:3142: bad switch statement ?
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.23
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-09 09:45 UTC by dcb
Modified: 2013-10-09 16:25 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dcb 2013-10-09 09:45:59 UTC
I just ran the static analyser cppcheck over the source code
of binutils-2.23.2

It said

[binutils-2.23.2/bfd/elf32-rx.c:3142] -> [binutils-2.23.2/bfd/elf32-rx.c:3143]: (warning) Variable 'st_info_str' is reassigned a value before the old one has been used. 'break;' missing?

Source code is

      switch (ELF_ST_TYPE (isym->st_info))
    {
    case STT_FUNC: st_info_str = "STT_FUNC";
    case STT_SECTION: st_info_str = "STT_SECTION";
    case STT_FILE: st_info_str = "STT_FILE";
    case STT_OBJECT: st_info_str = "STT_OBJECT";
    case STT_TLS: st_info_str = "STT_TLS";
    default: st_info_str = "";
    }
      switch (ELF_ST_BIND (isym->st_info))
    {
    case STB_LOCAL: st_info_stb_str = "STB_LOCAL";
    case STB_GLOBAL: st_info_stb_str = "STB_GLOBAL";
    default: st_info_stb_str = "";
    }
      switch (ELF_ST_VISIBILITY (isym->st_other))
    {
    case STV_DEFAULT: st_other_str = "STV_DEFAULT";
    case STV_INTERNAL: st_other_str = "STV_INTERNAL";
    case STV_PROTECTED: st_other_str = "STV_PROTECTED";
    default: st_other_str = "";
    }
      switch (isym->st_shndx)
    {
    case SHN_ABS: st_shndx_str = "SHN_ABS";
    case SHN_COMMON: st_shndx_str = "SHN_COMMON";
    case SHN_UNDEF: st_shndx_str = "SHN_UNDEF";
    default: st_shndx_str = "";
    }

Suggest add some break statements.
Comment 1 Sourceware Commits 2013-10-09 16:24:45 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2013-10-09 16:24:43

Modified files:
	bfd            : ChangeLog elf32-rx.c 

Log message:
	PR binutils/16022
	* elf32-rx.c (rx_dump_symtab): Add missing break statements.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.6156&r2=1.6157
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-rx.c.diff?cvsroot=src&r1=1.26&r2=1.27
Comment 2 Nick Clifton 2013-10-09 16:25:15 UTC
Patch applied.