Skip to contentSkip to conversation

xv: fix build warning regarding const qualifier

PATCH Superseded Rhys Kidd 2 participants 4 messages Jan 19, 2019 3 messages not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Rhys Kidd

author
#0 lore raw

PATCH 1/1 xv: fix build warning regarding const qualifier

Fixes warning with gcc 8.2:

nouveau_xv.c: In function ‘NVInitVideo’:
nouveau_xv.c:2247:68: warning: passing argument 2 of ‘vlCreateAdaptorXvMC’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

    adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen, textureAdaptor[0]->name);
                                                   ~~~~~~~~~~~~~~~~~^~~~~~
In file included from nouveau_xv.c:42:
vl_hwmc.h:6:63: note: expected ‘char *’ but argument is of type ‘const char *’
 XF86MCAdaptorPtr vlCreateAdaptorXvMC(ScreenPtr pScreen, char *xv_adaptor_name);
                                                         ~~~~~~^~~~~~~~~~~~~~~
---
 src/nouveau_xv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/nouveau_xv.c +1 -1
index a7ec21a..3258ef7 100644
@@ -2244,7 +2244,7 @@ NVInitVideo(ScreenPtr pScreen)
 		XF86MCAdaptorPtr *adaptorsXvMC = malloc(sizeof(XF86MCAdaptorPtr));
 		
 		if (adaptorsXvMC) {
-			adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen, textureAdaptor[0]->name);
+			adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen, (char *)textureAdaptor[0]->name);
 			
 			if (adaptorsXvMC[0]) {
 				vlInitXvMC(pScreen, 1, adaptorsXvMC);
Signature · 6 lines
2.19.1

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 20190119233042.7979-1-rhyskidd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

Is vlCreateAdaptorXvMC just silly, or does it really want to take ownership of the name pointer?

Quoted 33 lines · Rhys Kidd

Fixes warning with gcc 8.2:

nouveau_xv.c: In function ‘NVInitVideo’:
nouveau_xv.c:2247:68: warning: passing argument 2 of ‘vlCreateAdaptorXvMC’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

    adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen, textureAdaptor[0]->name);
                                                   ~~~~~~~~~~~~~~~~~^~~~~~
In file included from nouveau_xv.c:42:
vl_hwmc.h:6:63: note: expected ‘char *’ but argument is of type ‘const char *’
 XF86MCAdaptorPtr vlCreateAdaptorXvMC(ScreenPtr pScreen, char *xv_adaptor_name);
                                                         ~~~~~~^~~~~~~~~~~~~~~
---
 src/nouveau_xv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/nouveau_xv.c +1 -2
index a7ec21a..3258ef7 100644
@@ -2244,7 +2244,7 @@ NVInitVideo(ScreenPtr pScreen)
                XF86MCAdaptorPtr *adaptorsXvMC = malloc(sizeof(XF86MCAdaptorPtr));
 
                if (adaptorsXvMC) {
-                       adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen, textureAdaptor[0]->name);
+                       adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen, (char *)textureAdaptor[0]->name);
 
                        if (adaptorsXvMC[0]) {
                                vlInitXvMC(pScreen, 1, adaptorsXvMC);
--

2.19.1

Quoted 4 lines

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): CAKb7UvgS66eSyEWj-3k5kjvEffmpG5Oyu1h66xYcTBET7FfSuQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#4 lore raw
Quoted 3 lines · Ilia Mirkin

Is vlCreateAdaptorXvMC just silly, or does it really want to take ownership of the name pointer?

vlCreateAdaptorXvMC( ) doesn't need to take over ownership of the name pointer, so yes - I guess it's being silly in one respect by not being specific about const.

Quoted 34 lines · Rhys Kidd
Quoted 5 lines

Fixes warning with gcc 8.2:

nouveau_xv.c: In function ‘NVInitVideo’:
nouveau_xv.c:2247:68: warning: passing argument 2 of

‘vlCreateAdaptorXvMC’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

Quoted 1 line

adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen,

textureAdaptor[0]->name);

Quoted 1 line

~~~~~~~~~~~~~~~~~^~~~~~

Quoted 2 lines

In file included from nouveau_xv.c:42:
vl_hwmc.h:6:63: note: expected ‘char *’ but argument is of type ‘const

char *’

Quoted 1 line

XF86MCAdaptorPtr vlCreateAdaptorXvMC(ScreenPtr pScreen, char

*xv_adaptor_name);

Quoted 1 line

~~~~~~^~~~~~~~~~~~~~~

src/nouveau_xv.c NVInitVideo(ScreenPtr pScreen) · line 2244

Quoted 12 lines
---
 src/nouveau_xv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/nouveau_xv.c +0 -0
index a7ec21a..3258ef7 100644
@@ -2244,7 +2244,7 @@ NVInitVideo(ScreenPtr pScreen)
                XF86MCAdaptorPtr *adaptorsXvMC =

malloc(sizeof(XF86MCAdaptorPtr));

Quoted 1 line
Quoted 16 lines
Quoted 2 lines
                if (adaptorsXvMC) {

- adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen,

textureAdaptor[0]->name);

Quoted 1 line

+ adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen,

(char *)textureAdaptor[0]->name);

Quoted 10 lines
                        if (adaptorsXvMC[0]) {
                                vlInitXvMC(pScreen, 1, adaptorsXvMC);

--
2.19.1

_______________________________________________
Nouveau mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): CA+iOQUHmKdwSzsySzfp+yJX9D9n=Xjf=wg1JvnAmb1y=VTjNbQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

Reviewed-by
#6 lore raw
Quoted 8 lines · Rhys Kidd
Quoted 3 lines · Ilia Mirkin

Is vlCreateAdaptorXvMC just silly, or does it really want to take ownership of the name pointer?

vlCreateAdaptorXvMC( ) doesn't need to take over ownership of the name pointer, so yes - I guess it's being silly in one respect by not being specific about const.

OK. I'm not a fan of these types of casts, but it's also pretty minor. However I'd appreciate the subject getting renamed to "silence" rather than "fix", since it's not fixing anything (in fact it's arguably introducing a bug).

Quoted 37 lines
Quoted 37 lines · Rhys Kidd
Quoted 33 lines

Fixes warning with gcc 8.2:

nouveau_xv.c: In function ‘NVInitVideo’:
nouveau_xv.c:2247:68: warning: passing argument 2 of ‘vlCreateAdaptorXvMC’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

    adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen, textureAdaptor[0]->name);
                                                   ~~~~~~~~~~~~~~~~~^~~~~~
In file included from nouveau_xv.c:42:
vl_hwmc.h:6:63: note: expected ‘char *’ but argument is of type ‘const char *’
 XF86MCAdaptorPtr vlCreateAdaptorXvMC(ScreenPtr pScreen, char *xv_adaptor_name);
                                                         ~~~~~~^~~~~~~~~~~~~~~
---
 src/nouveau_xv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/nouveau_xv.c +1 -2
index a7ec21a..3258ef7 100644
@@ -2244,7 +2244,7 @@ NVInitVideo(ScreenPtr pScreen)
                XF86MCAdaptorPtr *adaptorsXvMC = malloc(sizeof(XF86MCAdaptorPtr));
 
                if (adaptorsXvMC) {
-                       adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen, textureAdaptor[0]->name);
+                       adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen, (char *)textureAdaptor[0]->name);
 
                        if (adaptorsXvMC[0]) {
                                vlInitXvMC(pScreen, 1, adaptorsXvMC);
--

2.19.1

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau