[Mesa-dev] [PATCH 32/38] dri_util: constify __DRI*Extension handling

Emil Velikov emil.l.velikov at gmail.com
Wed Feb 12 19:23:03 PST 2014


On 13/02/14 03:11, Ilia Mirkin wrote:
> On Wed, Feb 12, 2014 at 8:17 PM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
>> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
>> ---
>>  src/mesa/drivers/dri/common/dri_util.c | 12 ++++++------
>>  src/mesa/drivers/dri/common/dri_util.h |  8 ++++----
>>  2 files changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
>> index c4ff9c7..688d186 100644
>> --- a/src/mesa/drivers/dri/common/dri_util.c
>> +++ b/src/mesa/drivers/dri/common/dri_util.c
>> @@ -72,15 +72,15 @@ setupLoaderExtensions(__DRIscreen *psp,
>>
>>      for (i = 0; extensions[i]; i++) {
>>         if (strcmp(extensions[i]->name, __DRI_DRI2_LOADER) == 0)
>> -           psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i];
>> +           psp->dri2.loader = (const __DRIdri2LoaderExtension *) extensions[i];
> 
> Do these changes actually get you anything? It should be the case that
> 
> const T* x = (T*)y
> 
> shouldn't generate a warning. The reverse does, of course.
> 
Haven't been compiling and watching the output on each commit, but I
must admit these can be dropped. I've just sed the whole of mesa and
split that up into patches :)

-Emil

>>         if (strcmp(extensions[i]->name, __DRI_IMAGE_LOOKUP) == 0)
>> -           psp->dri2.image = (__DRIimageLookupExtension *) extensions[i];
>> +           psp->dri2.image = (const __DRIimageLookupExtension *) extensions[i];
>>         if (strcmp(extensions[i]->name, __DRI_USE_INVALIDATE) == 0)
>> -           psp->dri2.useInvalidate = (__DRIuseInvalidateExtension *) extensions[i];
>> +           psp->dri2.useInvalidate = (const __DRIuseInvalidateExtension *) extensions[i];
>>         if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0)
>> -           psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i];
>> +           psp->swrast_loader = (const __DRIswrastLoaderExtension *) extensions[i];
>>          if (strcmp(extensions[i]->name, __DRI_IMAGE_LOADER) == 0)
>> -           psp->image.loader = (__DRIimageLoaderExtension *) extensions[i];
>> +           psp->image.loader = (const __DRIimageLoaderExtension *) extensions[i];
>>      }
>>  }
>>
>> @@ -131,7 +131,7 @@ driCreateNewScreen2(int scrn, int fd,
>>         for (int i = 0; driver_extensions[i]; i++) {
>>            if (strcmp(driver_extensions[i]->name, __DRI_DRIVER_VTABLE) == 0) {
>>               psp->driver =
>> -                ((__DRIDriverVtableExtension *)driver_extensions[i])->vtable;
>> +                ((const __DRIDriverVtableExtension *)driver_extensions[i])->vtable;
>>            }
>>         }
>>      }
>> diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
>> index a37a0bb..1138bf1 100644
>> --- a/src/mesa/drivers/dri/common/dri_util.h
>> +++ b/src/mesa/drivers/dri/common/dri_util.h
>> @@ -174,13 +174,13 @@ struct __DRIscreenRec {
>>      struct {
>>         /* Flag to indicate that this is a DRI2 screen.  Many of the above
>>          * fields will not be valid or initializaed in that case. */
>> -       __DRIdri2LoaderExtension *loader;
>> -       __DRIimageLookupExtension *image;
>> -       __DRIuseInvalidateExtension *useInvalidate;
>> +       const __DRIdri2LoaderExtension *loader;
>> +       const __DRIimageLookupExtension *image;
>> +       const __DRIuseInvalidateExtension *useInvalidate;
>>      } dri2;
>>
>>      struct {
>> -        __DRIimageLoaderExtension *loader;
>> +        const __DRIimageLoaderExtension *loader;
>>      } image;
>>
>>      driOptionCache optionInfo;
>> --
>> 1.8.5.4
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev



More information about the mesa-dev mailing list