From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSL4z-0000J8-Pf for qemu-devel@nongnu.org; Wed, 27 Jul 2016 05:24:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSL4w-0000I5-Kt for qemu-devel@nongnu.org; Wed, 27 Jul 2016 05:24:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50870) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSL4w-0000GK-CX for qemu-devel@nongnu.org; Wed, 27 Jul 2016 05:24:38 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6R9JxUq047106 for ; Wed, 27 Jul 2016 05:24:35 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 24dyqpmq99-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 27 Jul 2016 05:24:34 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Jul 2016 10:24:31 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 5EC3A17D805F for ; Wed, 27 Jul 2016 10:26:02 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u6R9OTvu32637154 for ; Wed, 27 Jul 2016 09:24:29 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u6R8OVRx009382 for ; Wed, 27 Jul 2016 02:24:31 -0600 From: Sascha Silbe Date: Wed, 27 Jul 2016 11:24:26 +0200 Message-Id: <1469611466-31574-1-git-send-email-silbe@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] error: error_setg_errno(): errno gets preserved List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Markus Armbruster , Max Reitz , Halil Pasic , Kevin Wolf , Cornelia Huck , Michael Roth , Eric Blake C11 allows errno to be clobbered by pretty much any library function call, so in general callers need to take care to save errno before calling other functions. However, for error reporting functions this is rather awkward and can make the code on the caller side more complicated than necessary. error_setg_errno() already takes care of preserving errno and some functions rely on that, so just promise that we continue to do so in the future. Signed-off-by: Sascha Silbe --- Alternative approach to "error: error_setg_errno(): errno may be clobbered" [1]. [1] mid:1469558699-23314-1-git-send-email-silbe@linux.vnet.ibm.com "[Qemu-devel] [PATCH] error: error_setg_errno(): errno may be clobbered" by Sascha Silbe , sent on 2016-07-26. include/qapi/error.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/qapi/error.h b/include/qapi/error.h index 0576659..7e532d0 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -170,6 +170,9 @@ void error_setg_internal(Error **errp, * Just like error_setg(), with @os_error info added to the message. * If @os_error is non-zero, ": " + strerror(os_error) is appended to * the human-readable error message. + * + * The value of errno (which usually can get clobbered by almost any + * function call) will be preserved. */ #define error_setg_errno(errp, os_error, fmt, ...) \ error_setg_errno_internal((errp), __FILE__, __LINE__, __func__, \ -- 1.9.1