drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var
PATCH 1/1 drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var
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.
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=0 or ...=1 including the trailing NUL-letter. That is, the '\n' found in the format string is always cut off as a result.
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.
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 truncated before the last format character [-Werror=format-truncation=]
snprintf(display_ready_str, 20, "GVT_DISPLAY_READY=%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=%d\n", ready);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1025903
--- drivers/gpu/drm/i915/gvt/handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/handlers.c +1 -1
@@ -1039,7 +1039,7 @@ static int send_display_ready_uevent(struct intel_vgpu *vgpu, int ready)char vmid_str[20 ];char display_ready_str[20 ]; -snprintf (display_ready_str,20 ,"GVT_DISPLAY_READY=%d\n" , ready); +snprintf (display_ready_str,20 ,"GVT_DISPLAY_READY=%d" , ready); env[0 ] = display_ready_str;snprintf (vmid_str,20 ,"VMID=%d" , vgpu->id);
Signature · 6 lines
2.11.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var
== Series Details ==
== Series Details ==
Series: drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var
URL : https://patchwork.freedesktop.org/series/19952/
State : success
== Summary ==
Series 19952v1 drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var
https://patchwork.freedesktop.org/api/1.0/series/19952/revisions/1/mbox/
fi-bdw-5557u total:252 pass:241 dwarn:0 dfail:0 fail:0 skip:11 fi-bsw-n3050 total:252 pass:213 dwarn:0 dfail:0 fail:0 skip:39 fi-bxt-j4205 total:252 pass:233 dwarn:0 dfail:0 fail:0 skip:19 fi-bxt-t5700 total:83 pass:70 dwarn:0 dfail:0 fail:0 skip:12 fi-byt-j1900 total:252 pass:225 dwarn:0 dfail:0 fail:0 skip:27 fi-byt-n2820 total:252 pass:221 dwarn:0 dfail:0 fail:0 skip:31 fi-hsw-4770 total:252 pass:236 dwarn:0 dfail:0 fail:0 skip:16 fi-hsw-4770r total:252 pass:236 dwarn:0 dfail:0 fail:0 skip:16 fi-ilk-650 total:252 pass:202 dwarn:0 dfail:0 fail:0 skip:50 fi-ivb-3520m total:252 pass:234 dwarn:0 dfail:0 fail:0 skip:18 fi-ivb-3770 total:252 pass:234 dwarn:0 dfail:0 fail:0 skip:18 fi-kbl-7500u total:252 pass:234 dwarn:0 dfail:0 fail:0 skip:18 fi-skl-6260u total:252 pass:242 dwarn:0 dfail:0 fail:0 skip:10 fi-skl-6700hq total:252 pass:235 dwarn:0 dfail:0 fail:0 skip:17 fi-skl-6700k total:252 pass:230 dwarn:4 dfail:0 fail:0 skip:18 fi-skl-6770hq total:252 pass:242 dwarn:0 dfail:0 fail:0 skip:10 fi-snb-2520m total:252 pass:224 dwarn:0 dfail:0 fail:0 skip:28 fi-snb-2600 total:252 pass:223 dwarn:0 dfail:0 fail:0 skip:29
45a2990174f3cf4dfa5d07b204d17b11d6a7410a drm-tip: 2017y-02m-20d-12h-54m-53s UTC integration manifest 5435d46 drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3900/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Zhenyu Wang
AppliedQuoted 26 lines · Takashi Iwai
send_display_send_uevent()sends two environment variable, and the first oneGVT_DISPLAY_READYis 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.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=0 or ...=1 including the trailing NUL-letter. That is, the '\n' found in the format string is always cut off as a result.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.
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 truncated before the last format character [-Werror=format-truncation=]snprintf(display_ready_str, 20, "GVT_DISPLAY_READY=%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=%d\n", ready); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
Fixes 04d348ae3f0a ("drm/i915/gvt: vGPU display virtualization")Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1025903
Reported-by Richard Biener <[email protected]>Cc <[email protected]>Signed-off-by Takashi Iwai <[email protected]>---
Applied. Thanks!
Quoted 23 lines
drivers/gpu/drm/i915/gvt/handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/gvt/handlers.c +1
-1@@ -1039,7 +1039,7 @@ static int send_display_ready_uevent(struct intel_vgpu *vgpu, int ready)char vmid_str[20 ];char display_ready_str[20 ]; -snprintf (display_ready_str,20 ,"GVT_DISPLAY_READY=%d\n" , ready); +snprintf (display_ready_str,20 ,"GVT_DISPLAY_READY=%d" , ready); env[0 ] = display_ready_str;snprintf (vmid_str,20 ,"VMID=%d" , vgpu->id);Signature · 6 lines
2.11.1 _______________________________________________ intel-gvt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
Signature · 3 lines
Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx