Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wformat= in make step at v4l2loopback-ctl compilation #426

Closed
RobsonLana opened this issue Apr 26, 2021 · 4 comments
Closed

-Wformat= in make step at v4l2loopback-ctl compilation #426

RobsonLana opened this issue Apr 26, 2021 · 4 comments

Comments

@RobsonLana
Copy link

Sometimes, when I recompile (after a clean on the modules), the v4l2loopback-ctl fails at compilation; I had a lucky time when it not happened, but I am stuck again on this:

v4l2loopback-ctl.c:441:27: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘struct v4l2_loopback_config *’ [-Wformat=]
  441 |   printf("configuration: %s\n", cfg);
      |                          ~^     ~~~
      |                           |     |
      |                           |     struct v4l2_loopback_config *
      |                           char *
v4l2loopback-ctl.c: In function ‘parse_caps’:
v4l2loopback-ctl.c:660:24: warning: format ‘%c’ expects argument of type ‘char *’, but argument 3 has type ‘char (*)[5]’ [-Wformat=]
  660 |  if (sscanf(buffer, "%4c:%dx%d@%d/%d", &fourcc, &caps->width,
      |                      ~~^               ~~~~~~~
      |                        |               |
      |                        char *          char (*)[5]

I tried a few changes, but I got nothing; how could I correct this in the source file I have in my computer?

@umlaeute
Copy link
Owner

these are warnings, and as such they are not fatal to the build process.
unless you (or something else; but nothing on the side of this repository) marks warnings as errors with -Werror.

i'm closing this, as not actable upon.
if you can come up with actual errors, please don't hesitate to add them to this ticket and I will consider re-opening it.

@BenBE
Copy link
Contributor

BenBE commented Apr 26, 2021

Looking at

static void print_conf(struct v4l2_loopback_config *cfg)
{
MARK();
if (!cfg) {
printf("configuration: %s\n", cfg);
return;
}
MARK();
I see a straight forward type confusion. You are reading memory straight from a structure, when you'd actually want to format the structure's content into something readable for the user. Oh, and on second glance I also see a NULL dereference, as cfg is guaranteed NULL by the line just before the printf.

For the second warning you'd probably want to use %4s instead of the %4c the compiler complains about. Also the &fourcc should likely just be fourcc.

Please take warnings seriously.

@umlaeute
Copy link
Owner

Oh, and on second glance I also see a NULL dereference

ah well, i figure that "%s", 0 would print as (null). but of course this nevertheless should read %p instead of %s.

For the second warning you'd probably want to use %4s instead of the %4c

most certainly not. the FOURCC string can contain (trailing) spaces (e.g. V4L2_PIX_FMT_Y16)

Also the &fourcc should likely just be fourcc.

yes.

umlaeute added a commit that referenced this issue Apr 26, 2021
@RobsonLana
Copy link
Author

the %p for cfg at line 441 and fourcc instead of &fourcc at line 660 worked for compiling the code. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants