[PATCH 1/9] dmx: Fix a non-constant printf format string warning.

walter harms wharms at bfs.de
Sat Sep 17 03:46:14 PDT 2011



Am 17.09.2011 10:22, schrieb Jamey Sharp:
> Signed-off-by: Jamey Sharp <jamey at minilop.net>
> ---
>  hw/dmx/input/lnx-keyboard.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/dmx/input/lnx-keyboard.c b/hw/dmx/input/lnx-keyboard.c
> index 5bfb881..5b92f3b 100644
> --- a/hw/dmx/input/lnx-keyboard.c
> +++ b/hw/dmx/input/lnx-keyboard.c
> @@ -429,11 +429,11 @@ static int kbdLinuxOpenVT(int vtno)
>  {
>      int        fd = -1;
>      int        i;
> -    const char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
> +    const char *vcs[] = { "/dev/vc/", "/dev/tty", NULL };
>      char       name[64];        /* RATS: Only used in XmuSnprintf */
>  
>      for (i = 0; vcs[i]; i++) {
> -        XmuSnprintf(name, sizeof(name), vcs[i], vtno);
> +        XmuSnprintf(name, sizeof(name), "%s%d", vcs[i], vtno);
>          if ((fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0) break;
>      }
>      if (fd < 0)

XmuSnprintf can be replaces with snprintf()
so this may look like:

for (i = 0; vcs[i]; i++) {
 char       name[64];
 snprintf(name, sizeof(name), "%s%d", vcs[i], vtno);
 fd = open(name, O_RDWR | O_NONBLOCK, 0);
 if (fd >= 0) return fd;
}






More information about the xorg-devel mailing list