From: Jan Vesely Subject: Re: [PATCH 2/2] Fix one warning Date: Tue, 28 Apr 2015 10:28:30 -0400 Message-ID: <1430231310.28400.3.camel@rutgers.edu> References: <1429847046-12807-1-git-send-email-Jammy.Zhou@amd.com> <1429847046-12807-2-git-send-email-Jammy.Zhou@amd.com> <1429885818.6006.11.camel@rutgers.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1131087560==" Return-path: Received: from mail-vn0-f51.google.com (mail-vn0-f51.google.com [209.85.216.51]) by gabe.freedesktop.org (Postfix) with ESMTP id 7716D6E089 for ; Tue, 28 Apr 2015 07:28:35 -0700 (PDT) Received: by vnbg7 with SMTP id g7so16287826vnb.10 for ; Tue, 28 Apr 2015 07:28:34 -0700 (PDT) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: "Zhou, Jammy" Cc: "Min, Frank" , "dri-devel@lists.freedesktop.org" List-Id: dri-devel@lists.freedesktop.org --===============1131087560== Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-EkDtsPk33vk0lg8APomO" --=-EkDtsPk33vk0lg8APomO Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2015-04-27 at 01:40 +0000, Zhou, Jammy wrote: > Thanks for sharing the background. For [0], you mentioned that > get_perms may return -1 in some cases for the group, can you help > indicate which case it is? The one i found is in xserver: dri_drm_get_perms (hw/xfree86/dri/dri.c:759) copies values from xf86ConfigDRI. xf86configDRI is initialized in configDRI(hw/xfree86/common/xf86Config.c:2166). However, the default value if the DRI section is not present or does not contain group setting is -1. it looks like it relies on libdrm to fall back to default in that case, and it looks like that path currently broken I don't claim to fully understand what that old code is doing/supposed to do, but scanning through it suggests that negative values are legal way to report errors/undefined values. there might be other users as well jan >=20 > Since the drmSetServerInfo is seldom used, maybe we can just do the > 'int' cast at this moment. I will send v2 for this. >=20 > Regards, > Jammy >=20 > -----Original Message----- > From: Jan Vesely [mailto:jv356@scarletmail.rutgers.edu] On Behalf Of Jan = Vesely > Sent: Friday, April 24, 2015 10:30 PM > To: Zhou, Jammy > Cc: dri-devel@lists.freedesktop.org; Min, Frank > Subject: Re: [PATCH 2/2] Fix one warning >=20 > On Fri, 2015-04-24 at 11:44 +0800, Jammy Zhou wrote: > > xf86drm.c:356:2: warning: comparison of unsigned expression >=3D 0 is a= lways true [-Wtype-limits] > > group =3D (serv_group >=3D 0) ? serv_group : DRM_DEV_GID; > > ^ > >=20 > > Signed-off-by: Jammy Zhou > > --- > > xf86drm.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > >=20 > > diff --git a/xf86drm.c b/xf86drm.c > > index 4d67861..fbda2aa 100644 > > --- a/xf86drm.c > > +++ b/xf86drm.c > > @@ -353,7 +353,7 @@ static int drmOpenDevice(dev_t dev, int minor, int = type) > > } > > =20 > > if (drm_server_info) { > > - group =3D (serv_group >=3D 0) ? serv_group : DRM_DEV_GID; > > + group =3D serv_group; >=20 > I don't think this change is correct. get_perms can return errors as nega= tive values. I found that xserver does, see [0] for my take on fixing this,= as well as Emil's response [1]. >=20 > I think changing the condition to: > ((int)serv_group >=3D 0) >=20 > should be ok(I don't think there are systems with GID_MAX greater than 2^= 31-1), but I never bothered sending v2. >=20 > jan >=20 >=20 > [0]http://lists.freedesktop.org/archives/dri-devel/2015-February/077276.h= tml > [1]http://lists.freedesktop.org/archives/dri-devel/2015-February/078171.h= tml >=20 >=20 >=20 > > chown_check_return(buf, user, group); > > chmod(buf, devmode); > > } >=20 >=20 > -- > Jan Vesely --=20 Jan Vesely --=-EkDtsPk33vk0lg8APomO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCgAGBQJVP5kOAAoJEDhUsXb6ZiH/PfkP/1UHWAaSMiIxpZQtdu8HLbsK CWbReQJHnuelGUFMHYnPjSZ8u3oxUc36ticTVQwBIlL2j48FYRxf4qZ6swaC/46J mQsVkRRs/q5q5U99IERD0ulyl7Nqv73iCV2w/TKGgVZnmowrvKnrj81HiugHoT6V dv+IlCg6wp6CKTVlzbkvNnP3KK+xIbzhJ6HZ5mpY2bVlseDdH3cZ3CVxWIH6K1Jt p8zgQyVQ7rr8WB+eYCLLkKMFKmxc4UR4VpxLZGepl+HniA/GER6qID8pI4lQdDb3 3HYo2qxhXBEzG1Ya1jPqlHXVUBdgiZJUJFblVSwy7iJ1sab2RZs6NRx6NFDyszjG 8fW7J9s/nZWCCk67YpuhmkNU4DDx+djds2E34LM9QcMdTAN70dtvO3cqEJtQbgDj epjJ0lhKoxYiFEfC5RgoEuiY4jlqOPFXidbwBpznT0SqJgXcffWjQbDRPIh2txGb RD5bcutTlSnTeTEAcBuqbenLzjNfpfdQGjSJo+VWLj4x8AJgBCPFP/2O5Hmlou/T 0iRLVRPWhR3zDrjjru8JnEXTqT4LqCZRGImyeNTBWZ0+SV4VUFpDYOi16XrZIpFt OahyLB1SP8DP1VMTpaRxfe4gYOSvTuWictlU7YDDjxKYolnvBemxDYiIZXv8LukG UryiHmsVbcTn8Ait6jbM =ZAkU -----END PGP SIGNATURE----- --=-EkDtsPk33vk0lg8APomO-- --===============1131087560== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9kcmktZGV2ZWwK --===============1131087560==--