From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zhenyu Wang Subject: Re: [PATCH] drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var Date: Tue, 21 Feb 2017 10:49:25 +0800 Message-ID: <20170221024925.7tzgcyr3sywbnznj@zhen-hp.sh.intel.com> References: <20170220135825.11430-1-tiwai@suse.de> Reply-To: Zhenyu Wang Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0405265220==" Return-path: In-Reply-To: <20170220135825.11430-1-tiwai@suse.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Takashi Iwai Cc: Richard Biener , intel-gfx@lists.freedesktop.org, Daniel Vetter , intel-gvt-dev@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org --===============0405265220== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="xn7iqc6apbltbc6n" Content-Disposition: inline --xn7iqc6apbltbc6n Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2017.02.20 14:58:25 +0100, Takashi Iwai wrote: > send_display_send_uevent() sends two environment variable, and the > first one GVT_DISPLAY_READY is set including a new line at the end of > the string; that is obviously superfluous and wrong -- at least, it > *looks* so when you only read the code. >=20 > However, it doesn't appear in the actual output by a (supposedly > unexpected) trick. The code uses snprintf() and truncates the string > in size 20 bytes. This makes the string as GVT_DISPLAY_READY=3D0 or > ...=3D1 including the trailing NUL-letter. That is, the '\n' found in > the format string is always cut off as a result. >=20 > Although the code gives the correct result, it is confusing. This > patch addresses it, just removing the superfluous '\n' from the format > string for avoiding further confusion. If the argument "ready" were > not a bool, the size 20 should be corrected as well. But it's a > bool, so we can leave the magic number 20 as is for now. >=20 > FWIW, the bug was spotted by a new GCC7 warning: > drivers/gpu/drm/i915/gvt/handlers.c: In function 'pvinfo_mmio_write': > drivers/gpu/drm/i915/gvt/handlers.c:1042:34: error: 'snprintf' output t= runcated before the last format character [-Werror=3Dformat-truncation=3D] > snprintf(display_ready_str, 20, "GVT_DISPLAY_READY=3D%d\n", ready); > ^~~~~~~~~~~~~~~~~~~~~~~~ > drivers/gpu/drm/i915/gvt/handlers.c:1042:2: note: 'snprintf' output 21 = bytes into a destination of size 20 > snprintf(display_ready_str, 20, "GVT_DISPLAY_READY=3D%d\n", ready); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >=20 > Fixes: 04d348ae3f0a ("drm/i915/gvt: vGPU display virtualization") > Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=3D1025903 > Reported-by: Richard Biener > Cc: > Signed-off-by: Takashi Iwai > --- Applied. Thanks! > drivers/gpu/drm/i915/gvt/handlers.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/g= vt/handlers.c > index 1d450627ff65..845aa1511cbf 100644 > --- a/drivers/gpu/drm/i915/gvt/handlers.c > +++ b/drivers/gpu/drm/i915/gvt/handlers.c > @@ -1039,7 +1039,7 @@ static int send_display_ready_uevent(struct intel_v= gpu *vgpu, int ready) > char vmid_str[20]; > char display_ready_str[20]; > =20 > - snprintf(display_ready_str, 20, "GVT_DISPLAY_READY=3D%d\n", ready); > + snprintf(display_ready_str, 20, "GVT_DISPLAY_READY=3D%d", ready); > env[0] =3D display_ready_str; > =20 > snprintf(vmid_str, 20, "VMID=3D%d", vgpu->id); > --=20 > 2.11.1 >=20 > _______________________________________________ > intel-gvt-dev mailing list > intel-gvt-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev --=20 Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827 --xn7iqc6apbltbc6n Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iEYEARECAAYFAlirqrUACgkQsQQaM014GCf84gCfaHwwMyJ8k5cHQO3bHwcFJ9O0 chsAoI3ZSsKr3WGGQvxzEuTDNQ+Bi4xt =rLCa -----END PGP SIGNATURE----- --xn7iqc6apbltbc6n-- --===============0405265220== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vaW50ZWwtZ2Z4Cg== --===============0405265220==--