On Mon, May 12, 2025 at 10:41 AM T.J. Mercier <tjmerc...@google.com> wrote:
[...]
> +
> +static int udmabuf;

static int udmabuf = -1;

> +static const char udmabuf_test_buffer_name[DMA_BUF_NAME_LEN] = 
> "udmabuf_test_buffer_for_iter";
> +static size_t udmabuf_test_buffer_size;
> +static int sysheap_dmabuf;

static int sysheap_dmabuf = -1;

> +static const char sysheap_test_buffer_name[DMA_BUF_NAME_LEN] = 
> "sysheap_test_buffer_for_iter";
> +static size_t sysheap_test_buffer_size;
> +
> +static int create_udmabuf(void)
> +{
> +       struct udmabuf_create create;

nit: zero initialize create to be future proof.

> +       int dev_udmabuf, memfd, local_udmabuf;
> +
> +       udmabuf_test_buffer_size = 10 * getpagesize();

[...]

> +static void subtest_dmabuf_iter_check_default_iter(struct dmabuf_iter *skel)
> +{
> +       bool found_test_sysheap_dmabuf = false;
> +       bool found_test_udmabuf = false;
> +       struct DmabufInfo bufinfo;
> +       size_t linesize = 0;
> +       char *line = NULL;
> +       FILE *iter_file;
> +       int iter_fd, f = INODE;
> +
> +       iter_fd = bpf_iter_create(bpf_link__fd(skel->links.dmabuf_collector));
> +       ASSERT_OK_FD(iter_fd, "iter_create");

Should we check ASSERT_OK_FD() and exit early on
failures?

> +
> +       iter_file = fdopen(iter_fd, "r");
> +       ASSERT_OK_PTR(iter_file, "fdopen");

Same here.
[...]
> +/*
> + * Fields output by this iterator are delimited by newlines. Convert any
> + * newlines in user-provided printed strings to spaces.
> + */
> +static void sanitize_string(char *src, size_t size)
> +{
> +       for (char *c = src; c && (size_t)(c - src) < size; ++c)

Should this be:

  for (char *c = src; *c && (size_t)(c - src) < size; ++c)

?

Thanks,
Song

[...]

Reply via email to