summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2024-01-16 13:27:19 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-01-16 13:38:49 -0800
commit36ffdb5239a5f29179a0e09c839089e1704031ed (patch)
tree2ab220786ccc06a8da632398ad26d262b39a9e36
parent7899231c65d68d3b0cef0c5a3a5553d9d566ebdc (diff)
Fix -Wdiscarded-qualifiers warning in AddV4LEnc()HEADmaster
v4l.c: In function 'AddV4LEnc': v4l.c:920:16: warning: passing argument 1 of 'sprintf' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 920 | sprintf(enc->name,"%s-%s",norm,fixname(input)); | ~~~^~~~~~ In file included from v4l.c:20: /usr/include/stdio.h:363:38: note: expected 'char * restrict' but argument is of type 'const char *' 363 | extern int sprintf (char *__restrict __s, | ~~~~~~~~~~~~~~~~~^~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/v4l.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/v4l.c b/src/v4l.c
index 789fc5e..e0fdc45 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -908,16 +908,23 @@ static int
AddV4LEnc(XF86VideoEncodingPtr enc, int entry,
char *norm, char *input, int width, int height, int n, int d)
{
- enc->id = entry;
- enc->name = malloc(strlen(norm) + strlen(input) + 2);
- if (!enc->name)
+ char *name;
+
+#if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(10, 0)
+ if (Xasprintf(&name, "%s-%s", norm, fixname(input)) < 0)
+ name = NULL;
+#else
+ name = Xprintf("%s-%s", norm, fixname(input));
+#endif
+ if (name == NULL)
return -1;
+ enc->id = entry;
+ enc->name = name;
enc->width = width;
enc->height = height;
enc->rate.numerator = n;
enc->rate.denominator = d * 2; /* Refresh rate is twice, due to interlace */
- sprintf(enc->name,"%s-%s",norm,fixname(input));
xf86Msg(X_INFO, "v4l: adding input %s, %dx%d %d fps\n",
enc->name, enc->width, enc->height, (d + n - 1)/n);