From nobody Sun May 19 12:13:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1628525788; cv=none; d=zohomail.com; s=zohoarc; b=AO5asRuJ9u19HqzvKXzS07zVhYcAa/0pBuWhSZmFYEEztQ6Jk3w5RYXxQz+wRO2dUDYSoz7j0x5VGX5PBprExC92DuPhC2wGCte/+IMl4pSzSZmoge7pHXF2R53IVJc7RrIv/+xi+fUnt4zUdVfA90yTlU7WkzO9Bbw5vca0GpE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628525788; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=YChhRY1Q09WDANrUvOKZQuT7fzBpyWYMh1Yu12+F6OI=; b=HGwLuVaeaCPToFrf0ZEAyXBgfeClv/M0iIRuN3gRk6PCpPro16VzpXYkaRsxRH+/EWcB9KoJRiiRFwJDBRpvZPBhov7jaUH9TGXyGA+2iFTCTQ1CdSkyh46jhLQqIBbeCc3YUjZrJ+k29YLRZrUevVq9FQbJYBJ/VzoJOudJaA0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1628525788320731.5432616134224; Mon, 9 Aug 2021 09:16:28 -0700 (PDT) Received: from localhost ([::1]:49814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mD7ww-0002Nu-LP for importer@patchew.org; Mon, 09 Aug 2021 12:16:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mD7v4-0001TR-U9 for qemu-devel@nongnu.org; Mon, 09 Aug 2021 12:14:30 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:36679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mD7v2-0006B7-El for qemu-devel@nongnu.org; Mon, 09 Aug 2021 12:14:30 -0400 Received: by mail-wm1-x32e.google.com with SMTP id o7-20020a05600c5107b0290257f956e02dso15137150wms.1 for ; Mon, 09 Aug 2021 09:14:27 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id u11sm19924148wrt.89.2021.08.09.09.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 09:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YChhRY1Q09WDANrUvOKZQuT7fzBpyWYMh1Yu12+F6OI=; b=VdvtdjjlKTWOgABmUxs2T5UBXD54n6VJKs8vzQrlui6/vC0O0BihWedC5ZKQ5Ixr8a yc5P40hOYjXVK52iciWBccwZANJvS5WOSuKebjZreiKygFwF90CizpgxcXZx/MGq/4tu 6H2aHV7agwvCcrrShhpAO5DvJQtXcP9tfRx/OBiykHERXW8xAW7zmM3seplxoPBE+4Ut lrUYJ5JkrJaSKRF0CKgaP9uH4r8cnwOazrURpqLdI0V4kzizDOKgtK+cwXxSEkAUgeru nNfn4Pn0DVSefSOc4SglLK+7nJ1pHKshh63stKcgqc0hDQVDulRs8yS/4inZou/FE715 VZsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YChhRY1Q09WDANrUvOKZQuT7fzBpyWYMh1Yu12+F6OI=; b=r4NZMqrCVcitYGbmMvV8TlshX1lWpqB5UPgrb1nvWFFKS/txkrukrBJt4pu13U5OAJ qk0oJ5t2xBeQku7aIjTLInpR7iHtBcSNpgJbksn72UjaZBaYV4L+3gqEcr4Q9e2GQKBQ wfKmm8SWHMDhJhRGh2O2joMBcaIO7EvgFZT34PFJlofGLTLVkm5hvGHNzBxqsMDkIic4 Lbz2HbIDnaeIgMmSejP/LghNVPXLj0+ACqEiGvRKcr9a2RSpqAD3RH29/s42KfzBVqFT a5Jyv19YCCRA5t1HC88/BMbRhnPIQoj/PKbWHO6NrMniU/Ab4tR3wFiDhbG60cX2xKKX gCDA== X-Gm-Message-State: AOAM530YrgMZUesBImGiU+Q/eWuor5eHRWAqjQ/MbE+bWFfGlefte+lA vg42ZPjwHOGZ+v0ln0fsL9nU4WPIhAa0uw== X-Google-Smtp-Source: ABdhPJy8eUEZyuAnd8HCpztivigxi6Z8GasSeciziJNbNhk0Tqoe4v567PHLXflFJEP/bbUyHE+iXA== X-Received: by 2002:a1c:2b04:: with SMTP id r4mr17880469wmr.168.1628525666275; Mon, 09 Aug 2021 09:14:26 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH] ui/sdl2: Check return value from g_setenv() Date: Mon, 9 Aug 2021 17:14:24 +0100 Message-Id: <20210809161424.32355-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1628525790543100001 Content-Type: text/plain; charset="utf-8" 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 --- 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, Displa= yOptions *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 variabl= e\n"); + exit(1); + } #endif =20 if (SDL_Init(SDL_INIT_VIDEO)) { --=20 2.20.1