diff mbox

[libdrm,3/2] Fix always true comparison.

Message ID 1423527043-21264-1-git-send-email-jan.vesely@rutgers.edu (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Vesely Feb. 10, 2015, 12:10 a.m. UTC
The only user I found is xserver, it can return -1 under certain conditions.
So check for -1 explicitly.

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
---

I could not find whether it's actually legal to return encoded negative values
in get_perm. This is a quick fix to detect the one case that I found.

 xf86drm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Vesely Feb. 25, 2015, 5:11 p.m. UTC | #1
gentle ping


On Mon, 2015-02-09 at 19:10 -0500, Jan Vesely wrote:
> The only user I found is xserver, it can return -1 under certain conditions.
> So check for -1 explicitly.
> 
> Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
> ---
> 
> I could not find whether it's actually legal to return encoded negative values
> in get_perm. This is a quick fix to detect the one case that I found.
> 
>  xf86drm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xf86drm.c b/xf86drm.c
> index fb673b5..8e54ac9 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -335,7 +335,7 @@ static int drmOpenDevice(dev_t dev, int minor, int type)
>  	drm_server_info->get_perms(&serv_group, &serv_mode);
>  	devmode  = serv_mode ? serv_mode : DRM_DEV_MODE;
>  	devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
> -	group = (serv_group >= 0) ? serv_group : DRM_DEV_GID;
> +	group = (serv_group != ~0U) ? serv_group : DRM_DEV_GID;
>      }
>  
>  #if !defined(UDEV)
Emil Velikov Feb. 25, 2015, 6:41 p.m. UTC | #2
On 25/02/15 17:11, Jan Vesely wrote:
> gentle ping
> 
Afaics it's very had to get in this code nowadays - drm_server_info is
set only via the legacy (?) function drmSetServerInfo. With the latter
only(?) used by the xserver when working with dri1 modules. So testing
this is likely to be very painful :-(

This code hasn't changed since before 2007, so I doubt there are many
people that know the details about it, so we might as well leave it for
now ?

-Emil

> 
> On Mon, 2015-02-09 at 19:10 -0500, Jan Vesely wrote:
>> The only user I found is xserver, it can return -1 under certain conditions.
>> So check for -1 explicitly.
>>
>> Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
>> ---
>>
>> I could not find whether it's actually legal to return encoded negative values
>> in get_perm. This is a quick fix to detect the one case that I found.
>>
>>  xf86drm.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/xf86drm.c b/xf86drm.c
>> index fb673b5..8e54ac9 100644
>> --- a/xf86drm.c
>> +++ b/xf86drm.c
>> @@ -335,7 +335,7 @@ static int drmOpenDevice(dev_t dev, int minor, int type)
>>  	drm_server_info->get_perms(&serv_group, &serv_mode);
>>  	devmode  = serv_mode ? serv_mode : DRM_DEV_MODE;
>>  	devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
>> -	group = (serv_group >= 0) ? serv_group : DRM_DEV_GID;
>> +	group = (serv_group != ~0U) ? serv_group : DRM_DEV_GID;
>>      }
>>  
>>  #if !defined(UDEV)
>
Jan Vesely March 2, 2015, 8:01 p.m. UTC | #3
On Wed, 2015-02-25 at 18:41 +0000, Emil Velikov wrote:
> On 25/02/15 17:11, Jan Vesely wrote:
> > gentle ping
> > 
> Afaics it's very had to get in this code nowadays - drm_server_info is
> set only via the legacy (?) function drmSetServerInfo. With the latter
> only(?) used by the xserver when working with dri1 modules. So testing
> this is likely to be very painful :-(
> 
> This code hasn't changed since before 2007, so I doubt there are many
> people that know the details about it, so we might as well leave it for
> now ?

fair enough. the warning fixes push it to non-libudev side, so it's not
going to bug me on every build.

jan

> 
> -Emil
> 
> > 
> > On Mon, 2015-02-09 at 19:10 -0500, Jan Vesely wrote:
> >> The only user I found is xserver, it can return -1 under certain conditions.
> >> So check for -1 explicitly.
> >>
> >> Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
> >> ---
> >>
> >> I could not find whether it's actually legal to return encoded negative values
> >> in get_perm. This is a quick fix to detect the one case that I found.
> >>
> >>  xf86drm.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/xf86drm.c b/xf86drm.c
> >> index fb673b5..8e54ac9 100644
> >> --- a/xf86drm.c
> >> +++ b/xf86drm.c
> >> @@ -335,7 +335,7 @@ static int drmOpenDevice(dev_t dev, int minor, int type)
> >>  	drm_server_info->get_perms(&serv_group, &serv_mode);
> >>  	devmode  = serv_mode ? serv_mode : DRM_DEV_MODE;
> >>  	devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
> >> -	group = (serv_group >= 0) ? serv_group : DRM_DEV_GID;
> >> +	group = (serv_group != ~0U) ? serv_group : DRM_DEV_GID;
> >>      }
> >>  
> >>  #if !defined(UDEV)
> > 
>
diff mbox

Patch

diff --git a/xf86drm.c b/xf86drm.c
index fb673b5..8e54ac9 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -335,7 +335,7 @@  static int drmOpenDevice(dev_t dev, int minor, int type)
 	drm_server_info->get_perms(&serv_group, &serv_mode);
 	devmode  = serv_mode ? serv_mode : DRM_DEV_MODE;
 	devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
-	group = (serv_group >= 0) ? serv_group : DRM_DEV_GID;
+	group = (serv_group != ~0U) ? serv_group : DRM_DEV_GID;
     }
 
 #if !defined(UDEV)