From patchwork Tue May 4 15:48:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Doucha X-Patchwork-Id: 1473901 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FZPQP4V7Hz9sPf for ; Wed, 5 May 2021 01:48:43 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 69EBF3C5833 for ; Tue, 4 May 2021 17:48:39 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 245883C582A for ; Tue, 4 May 2021 17:48:37 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 965481A006FD for ; Tue, 4 May 2021 17:48:36 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1BFBCAFC8 for ; Tue, 4 May 2021 15:48:36 +0000 (UTC) From: Martin Doucha To: ltp@lists.linux.it Date: Tue, 4 May 2021 17:48:32 +0200 Message-Id: <20210504154835.24881-3-mdoucha@suse.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210504154835.24881-1-mdoucha@suse.cz> References: <20210504154835.24881-1-mdoucha@suse.cz> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH v2 3/6] Add SAFE_IOCTL() variant for library code X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" SAFE_IOCTL() cannot be implemented as a function due to the variadic argument but the macro still needs a variant which accepts arbitrary file:line position for error messages as arguments. Signed-off-by: Martin Doucha --- Changes since v1: New patch include/tst_safe_macros.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h index d6f32ef4c..dcef58bda 100644 --- a/include/tst_safe_macros.h +++ b/include/tst_safe_macros.h @@ -211,13 +211,16 @@ pid_t safe_getpgid(const char *file, const int lineno, pid_t pid); #define SAFE_READDIR(dirp) \ safe_readdir(__FILE__, __LINE__, NULL, (dirp)) -#define SAFE_IOCTL(fd, request, ...) \ +#define SAFE_IOCTL_(file, lineno, fd, request, ...) \ ({int tst_ret_ = ioctl(fd, request, ##__VA_ARGS__); \ tst_ret_ < 0 ? \ - tst_brk(TBROK | TERRNO, \ + tst_brk_((file), (lineno), TBROK | TERRNO, \ "ioctl(%i,%s,...) failed", fd, #request), 0 \ : tst_ret_;}) +#define SAFE_IOCTL(fd, request, ...) \ + SAFE_IOCTL_(__FILE__, __LINE__, (fd), (request), ##__VA_ARGS__) + #define SAFE_FCNTL(fd, cmd, ...) \ ({int tst_ret_ = fcntl(fd, cmd, ##__VA_ARGS__); \ tst_ret_ == -1 ? \