• John Fastabend's avatar
    bpf: fix uninitialized variable in bpf tools · 81542556
    John Fastabend authored
    Here the variable cont is used as the saved_pointer for a call to
    strtok_r(). It is safe to use the value uninitialized in this
    context however and the later reference is only ever used if
    the strtok_r is successful. But, 'gcc-5' at least doesn't have all
    this knowledge so initialize cont to NULL. Additionally, do the
    natural NULL check before accessing just for completness.
    
    The warning is the following:
    
    ./bpf/tools/bpf/bpf_dbg.c: In function ‘cmd_load’:
    ./bpf/tools/bpf/bpf_dbg.c:1077:13: warning: ‘cont’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      } else if (matches(subcmd, "pcap") == 0) {
    
    Fixes: fd981e3c "filter: bpf_dbg: add minimal bpf debugger"
    Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    81542556
bpf_dbg.c 28.2 KB