From nobody Mon Feb 9 14:50:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571927558; cv=none; d=zoho.com; s=zohoarc; b=Yo4lyFykinxRoUGHw3+N4Q8TuXYCPBfBzGmVNzsLmRpDDC3goAPPaPQsSyYl6/wuTbH17GkHSurhQ8lAzh7QMz7WCU7s1w+wki68SfAkvfQ1dzEOwcXJx6ulfL3+vYiYCplYQUh62ga00qJSKBBP9UrzQGQWvxHvP4prR4nKhTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571927558; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=iL8S6iR4ZZdsmfsAcUJx7cMaYd8Hzxazv3RVTVkKUIU=; b=eDqUf3tUY4rbcJXSYYsBnrRp/4Ymro7vBsHB22cxah36VA5DtBkUOoCE6OjBTufQBu1AzpPfqGakhFbeP3wnwCOZATstKMwCa+2YOKGAA937drm5XwgbHVzrY04cAvSKSeCOnq5cxK/0Tgx4uo2ZhnqQQjd0nWsoKX4bevTjOAA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571927558086997.8060588952402; Thu, 24 Oct 2019 07:32:38 -0700 (PDT) Received: from localhost ([::1]:44296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNeAC-0003Dp-4y for importer@patchew.org; Thu, 24 Oct 2019 10:32:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34631) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNdih-0006x8-RV for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNdig-0007d5-JT for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:07 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:51392) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNdif-0007c4-Ou for qemu-devel@nongnu.org; Thu, 24 Oct 2019 10:04:06 -0400 Received: by mail-wm1-x343.google.com with SMTP id q70so3010998wme.1 for ; Thu, 24 Oct 2019 07:04:04 -0700 (PDT) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b7sm10610155wrn.53.2019.10.24.07.04.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Oct 2019 07:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=iL8S6iR4ZZdsmfsAcUJx7cMaYd8Hzxazv3RVTVkKUIU=; b=r5qECsBzMoHnH9oYTdqnwSkwxzMAcjqDHgOrOENov38N4SKCao4pyClT42QpKYifIx SZIUAJw3EL+zNKVP9N9KG7cS79k/tGMej1nPTKIQYeGXMNQG8wMobEQbhXcMYqoliLRP 6oCVCrSaVmUoUECfmTCHroDpy/+wvYUGKAwnkzxz3YpgPePlTv/RRxJWLWfVTe/KFkgr /AVxYOc6QbrO22odbMy/JkKZfWx5B9upbvVf7ma4WyH5OuI5t06BtKr1gjRm4xEeQVIb 32Jdm7a52ejFoo7VJq2JtXg14/GHXZw6kzu2+ijHfHrY/1sHc9eHSSVYm6oJ8MSoRL8g WrtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=iL8S6iR4ZZdsmfsAcUJx7cMaYd8Hzxazv3RVTVkKUIU=; b=QNp+1/qgS9Yc+3xUHDLxH18LSBUdiLgN0/5gfSuuPKJgdUJGe9WkbxRJbCDd4hTpzC p6PVbYpOeIYdH3oTrzPH3vDgMidpcjBtKlQK9bTcZoQL1RbqzC2W23+GgZcd/WC6+6cN V6y/AWA/o5ZMad6at6Eo9miItQhZmPngWg6Gaut2FhxGjsHfHkJ4NEHI1sih77/0r53e IPZhUqMUk/O7K/4RavfJieNLWATP5P7nVDkAsgj+Q9yK2RvMXwfsiRC+/upIjcpsd+PV uoif9QilS3lSnRr8grSQ3m4dl5fbWLX9AU1VxnqP2hO0f5jjqFtTAwwsXZLhjnyPWahy 93Kg== X-Gm-Message-State: APjAAAXF8sMU4kfS6rf4Dnm9Ll+g6g/+jaXcCE6AYCild+sJ4xXDx93A esNqfDul6UBvoTGJQMnPXYgVgAs8 X-Google-Smtp-Source: APXvYqx06gt8bV4kHJTdwiiTMWl8QalRrQ3caQB2z6aONCWr0QBxGt5XsfAj8EXyKTgjO1/8MqY9ag== X-Received: by 2002:a1c:7913:: with SMTP id l19mr5391774wme.26.1571925843125; Thu, 24 Oct 2019 07:04:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 05/39] Do not use %m in common code to print error messages Date: Thu, 24 Oct 2019 16:03:21 +0200 Message-Id: <1571925835-31930-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> References: <1571925835-31930-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 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: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The %m format specifier is an extension from glibc - and when compiling QEMU for NetBSD, the compiler correctly complains, e.g.: /home/qemu/qemu-test.ELjfrQ/src/util/main-loop.c: In function 'sigfd_handle= r': /home/qemu/qemu-test.ELjfrQ/src/util/main-loop.c:64:13: warning: %m is only allowed in syslog(3) like functions [-Wformat=3D] printf("read from sigfd returned %zd: %m\n", len); ^ Let's use g_strerror() here instead, which is an easy-to-use wrapper around the thread-safe strerror_r() function. While we're at it, also convert the "printf()" in main-loop.c into the preferred "error_report()". Signed-off-by: Thomas Huth Message-Id: <20191018130716.25438-1-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- hw/misc/tmp421.c | 4 ++-- util/main-loop.c | 3 ++- util/systemd.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c index 9f04470..c0bc150 100644 --- a/hw/misc/tmp421.c +++ b/hw/misc/tmp421.c @@ -120,7 +120,7 @@ static void tmp421_get_temperature(Object *obj, Visitor= *v, const char *name, int tempid; =20 if (sscanf(name, "temperature%d", &tempid) !=3D 1) { - error_setg(errp, "error reading %s: %m", name); + error_setg(errp, "error reading %s: %s", name, g_strerror(errno)); return; } =20 @@ -160,7 +160,7 @@ static void tmp421_set_temperature(Object *obj, Visitor= *v, const char *name, } =20 if (sscanf(name, "temperature%d", &tempid) !=3D 1) { - error_setg(errp, "error reading %s: %m", name); + error_setg(errp, "error reading %s: %s", name, g_strerror(errno)); return; } =20 diff --git a/util/main-loop.c b/util/main-loop.c index e3eaa55..eda63fe 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -61,7 +61,8 @@ static void sigfd_handler(void *opaque) } =20 if (len !=3D sizeof(info)) { - printf("read from sigfd returned %zd: %m\n", len); + error_report("read from sigfd returned %zd: %s", len, + g_strerror(errno)); return; } =20 diff --git a/util/systemd.c b/util/systemd.c index d22e86c..1dd0367 100644 --- a/util/systemd.c +++ b/util/systemd.c @@ -60,8 +60,8 @@ unsigned int check_socket_activation(void) * and we should exit. */ error_report("Socket activation failed: " - "invalid file descriptor fd =3D %d: %m", - fd); + "invalid file descriptor fd =3D %d: %s", + fd, g_strerror(errno)); exit(EXIT_FAILURE); } } --=20 1.8.3.1