Skip to content
Snippets Groups Projects
Forked from Reform / reform-boundary-uboot
Source project has a limited visibility.
  • Paul Burton's avatar
    e94136bd
    mips-relocs: Fix warning from gcc 6.3 · e94136bd
    Paul Burton authored
    
    It seems that gcc 6.3 at least is smart enough to warn about the _val
    variable being unassigned in the default case in the set_hdr_field()
    macro, but not smart enough to figure out that the default case is never
    taken. This results in warnings such as the following:
    
      pfx##hdr32[idx].field = _val;   \
                              ^
     ../tools/mips-relocs.c:51:11: note: _val was declared here
       uint64_t _val;      \
                ^
     ../tools/mips-relocs.c:88:2: note: in expansion of macro set_hdr_field
       set_hdr_field(p, idx, field, val)
       ^~~~~~~~~~~~~
     ../tools/mips-relocs.c:408:3: note: in expansion of macro set_phdr_field
        set_phdr_field(i, p_filesz, load_sz);
        ^~~~~~~~~~~~~~
     ../tools/mips-relocs.c: In function main:
     ../tools/mips-relocs.c:77:25: warning: _val may be used uninitialized
        in this function [-Wmaybe-uninitialized]
    
    Avoid this by assigning _val = 0 in the default case, and asserting that
    we didn't actually hit it for good measure.
    
    For reference gcc 7.1.1 seems to be smart enough to not hit the above
    warning without this patch.
    
    Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
    Fixes: 011dd93ca97a ("MIPS: Stop building position independent code")
    Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
    Cc: Tom Rini <trini@konsulko.com>
    Cc: u-boot@lists.denx.de
    e94136bd
    History
    mips-relocs: Fix warning from gcc 6.3
    Paul Burton authored
    
    It seems that gcc 6.3 at least is smart enough to warn about the _val
    variable being unassigned in the default case in the set_hdr_field()
    macro, but not smart enough to figure out that the default case is never
    taken. This results in warnings such as the following:
    
      pfx##hdr32[idx].field = _val;   \
                              ^
     ../tools/mips-relocs.c:51:11: note: _val was declared here
       uint64_t _val;      \
                ^
     ../tools/mips-relocs.c:88:2: note: in expansion of macro set_hdr_field
       set_hdr_field(p, idx, field, val)
       ^~~~~~~~~~~~~
     ../tools/mips-relocs.c:408:3: note: in expansion of macro set_phdr_field
        set_phdr_field(i, p_filesz, load_sz);
        ^~~~~~~~~~~~~~
     ../tools/mips-relocs.c: In function main:
     ../tools/mips-relocs.c:77:25: warning: _val may be used uninitialized
        in this function [-Wmaybe-uninitialized]
    
    Avoid this by assigning _val = 0 in the default case, and asserting that
    we didn't actually hit it for good measure.
    
    For reference gcc 7.1.1 seems to be smart enough to not hit the above
    warning without this patch.
    
    Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
    Fixes: 011dd93ca97a ("MIPS: Stop building position independent code")
    Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
    Cc: Tom Rini <trini@konsulko.com>
    Cc: u-boot@lists.denx.de