All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: andriin@fb.com
Cc: bpf@vger.kernel.org
Subject: [bug report] libbpf: use negative fd to specify missing BTF
Date: Wed, 12 Jun 2019 14:51:45 +0300	[thread overview]
Message-ID: <20190612115145.GA26292@mwanda> (raw)

Hello Andrii Nakryiko,

The patch fba01a0689a9: "libbpf: use negative fd to specify missing
BTF" from May 29, 2019, leads to the following static checker warning:

	./tools/lib/bpf/libbpf.c:1757 bpf_object__create_maps()
	warn: always true condition '(create_attr.btf_fd >= 0) => (0-u32max >= 0)'

./tools/lib/bpf/libbpf.c
  1735                  if (obj->caps.name)
  1736                          create_attr.name = map->name;
  1737                  create_attr.map_ifindex = map->map_ifindex;
  1738                  create_attr.map_type = def->type;
  1739                  create_attr.map_flags = def->map_flags;
  1740                  create_attr.key_size = def->key_size;
  1741                  create_attr.value_size = def->value_size;
  1742                  create_attr.max_entries = def->max_entries;
  1743                  create_attr.btf_fd = -1;
                        ^^^^^^^^^^^^^^^^^^^^^^^
.btf_fd is a __u32

  1744                  create_attr.btf_key_type_id = 0;
  1745                  create_attr.btf_value_type_id = 0;
  1746                  if (bpf_map_type__is_map_in_map(def->type) &&
  1747                      map->inner_map_fd >= 0)
  1748                          create_attr.inner_map_fd = map->inner_map_fd;
  1749  
  1750                  if (obj->btf && !bpf_map_find_btf_info(map, obj->btf)) {
  1751                          create_attr.btf_fd = btf__fd(obj->btf);
  1752                          create_attr.btf_key_type_id = map->btf_key_type_id;
  1753                          create_attr.btf_value_type_id = map->btf_value_type_id;
  1754                  }
  1755  
  1756                  *pfd = bpf_create_map_xattr(&create_attr);
  1757                  if (*pfd < 0 && create_attr.btf_fd >= 0) {
                                        ^^^^^^^^^^^^^^^^^^^^^^^
Always true condition.

  1758                          cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
  1759                          pr_warning("Error in bpf_create_map_xattr(%s):%s(%d). Retrying without BTF.\n",
  1760                                     map->name, cp, errno);
  1761                          create_attr.btf_fd = -1;
  1762                          create_attr.btf_key_type_id = 0;
  1763                          create_attr.btf_value_type_id = 0;
  1764                          map->btf_key_type_id = 0;
  1765                          map->btf_value_type_id = 0;
  1766                          *pfd = bpf_create_map_xattr(&create_attr);
  1767                  }

regards,
dan carpenter

             reply	other threads:[~2019-06-12 11:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 11:51 Dan Carpenter [this message]
2019-06-13  4:51 ` [bug report] libbpf: use negative fd to specify missing BTF Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190612115145.GA26292@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=andriin@fb.com \
    --cc=bpf@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.