From: Jan Vesely Subject: Re: [PATCH 2/2] Fix one warning Date: Mon, 27 Apr 2015 15:55:54 -0400 Message-ID: <1430164554.3625.59.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="===============1470041193==" Return-path: Received: from mail-qg0-f52.google.com (mail-qg0-f52.google.com [209.85.192.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6F886E23E for ; Wed, 6 Jan 2016 08:17:25 -0800 (PST) Received: by mail-qg0-f52.google.com with SMTP id e32so215818942qgf.3 for ; Wed, 06 Jan 2016 08:17:25 -0800 (PST) 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 --===============1470041193== Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-25KzU0aB6u9paizs1I+5" --=-25KzU0aB6u9paizs1I+5 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? in xserver: function dr_drm_get_perms (hw/xfree86/dri/dri.c:759) copies previously initialized values of xf86ConfigDRI. Those values are set in configDRI (hw/xfree86/common/xf86Config.c:2166), which is called from xf86HandleConfigFile (hw/xfree86/common/xf86Config.c:2479) and provided values parsed in xf86readConfigFile(hw/xfree86/parser/read.c:89), group is only set in dri section. I did not really look into details. to me it looks like -1 is stored in group unless there is a valid DRI section with group assigned name or gid. I did not look for other users of libdrm that might also use neg values to indicate errors. You might want to ask someone who is more familiar with the design than just reading the code (like I did) regards, 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 --=-25KzU0aB6u9paizs1I+5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCgAGBQJVPpRKAAoJEDhUsXb6ZiH/OqYP/1BIj+s3EIBm76D8IclF6myT N8oX+yBThFLWLHwtx3nook1Cgnw0RoXmCoPo1Boseun3n5y4qrCprCs8EDE/uRPa WHehpOA2VA3aTtx5Nc6pLmXy6fxanEdVEyltgGbliSGbM7MgvGRh71sKriwTfMsk W8S5zq0OsBNKOkx/4iiZG98K7g38ToKdl4sAHv5mF1bdZqJ2Kr48zlFnB6Pd2PLY w9/MtXBUekmJCcVmOT4nfN2TXBAX5p9cjrTQV+o8SVqq3IOuwC+AK9G+EijUcyJk 4mUhO0C/tfpcKO6odY3n7EhMX4aPQ1FH8EWIRKWM8K1qB67gtpBg5Kx26BUBbkye zZAk+pPsMKupHWLryGrwVp4gitqn2ZNYgQSpySSrQXd0S72ZVt1r+YvRI0FZzvwv prSyAkahO2JhlwHqQzin4XGtH3Lzaw9LI9NRidEGSGj7w5Clx5XyYOiMXJoLGXe1 Gnw87+3+bzX2Ao8VlTJAb7jMh+9kS9sihLcqzF6fmiAKrTPkrr0IeNq0oU+HLExp BKXvSNI6QaCzqJ99kvKP7dLwmT5HGzxkmq9fSbwVwzTyDWVtrnVdBKqsm5jW6G5e FFPNLbB8GuRKSu2RicMhWhm/rqreKHbNeu4osUv3I6ZTinLAQ7UXmckqNm5o+gnK JgIWTZbeAULHFsSQg912 =qg4s -----END PGP SIGNATURE----- --=-25KzU0aB6u9paizs1I+5-- --===============1470041193== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9kcmktZGV2ZWwK --===============1470041193==--