* [PATCH] ui/sdl2: Check return value from g_setenv()
@ 2021-08-09 16:14 Peter Maydell
2021-08-10 5:50 ` Gerd Hoffmann
2021-08-10 8:57 ` Gerd Hoffmann
0 siblings, 2 replies; 3+ messages in thread
From: Peter Maydell @ 2021-08-09 16:14 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Setting environment variables can fail; check the return value
from g_setenv() and bail out if we couldn't set SDL_VIDEODRIVER.
Fixes: Coverity 1458798
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
I followed existing practice in this function for how it
deals with errors (ie, fprintf to stderr and exit).
---
ui/sdl2.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 36d9010cb6c..17c0ec30ebf 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -817,7 +817,10 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
* This is a bit hackish but saves us from bigger problem.
* Maybe it's a good idea to fix this in SDL instead.
*/
- g_setenv("SDL_VIDEODRIVER", "x11", 0);
+ if (!g_setenv("SDL_VIDEODRIVER", "x11", 0)) {
+ fprintf(stderr, "Could not set SDL_VIDEODRIVER environment variable\n");
+ exit(1);
+ }
#endif
if (SDL_Init(SDL_INIT_VIDEO)) {
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ui/sdl2: Check return value from g_setenv()
2021-08-09 16:14 [PATCH] ui/sdl2: Check return value from g_setenv() Peter Maydell
@ 2021-08-10 5:50 ` Gerd Hoffmann
2021-08-10 8:57 ` Gerd Hoffmann
1 sibling, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2021-08-10 5:50 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel
Hi,
> Setting environment variables can fail; check the return value
> from g_setenv() and bail out if we couldn't set SDL_VIDEODRIVER.
Hmm, looking at the comment I'm wondering whenever we maybe should just
drop the setenv (after 6.1). It's quite old, I doubt svgalib talking
directly to the hardware is still a thing these days, and we have the
x11 -> wayland shift happening ...
take care,
Gerd
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ui/sdl2: Check return value from g_setenv()
2021-08-09 16:14 [PATCH] ui/sdl2: Check return value from g_setenv() Peter Maydell
2021-08-10 5:50 ` Gerd Hoffmann
@ 2021-08-10 8:57 ` Gerd Hoffmann
1 sibling, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2021-08-10 8:57 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel
On Mon, Aug 09, 2021 at 05:14:24PM +0100, Peter Maydell wrote:
> Setting environment variables can fail; check the return value
> from g_setenv() and bail out if we couldn't set SDL_VIDEODRIVER.
>
> Fixes: Coverity 1458798
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> I followed existing practice in this function for how it
> deals with errors (ie, fprintf to stderr and exit).
> ---
Queued for 6.1 (given that the "drop setenv altogether" idea clearly is
6.2 material).
thanks,
Gerd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-10 8:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 16:14 [PATCH] ui/sdl2: Check return value from g_setenv() Peter Maydell
2021-08-10 5:50 ` Gerd Hoffmann
2021-08-10 8:57 ` Gerd Hoffmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.