From nobody Tue May 7 18:28:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149916051318355.380925370209866; Tue, 4 Jul 2017 02:28:33 -0700 (PDT) Received: from localhost ([::1]:39837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSK8F-0004Rs-4g for importer@patchew.org; Tue, 04 Jul 2017 05:28:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSK6x-0003fH-T2 for qemu-devel@nongnu.org; Tue, 04 Jul 2017 05:27:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSK6t-0003G1-Ur for qemu-devel@nongnu.org; Tue, 04 Jul 2017 05:27:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dSK6t-0003FT-O9 for qemu-devel@nongnu.org; Tue, 04 Jul 2017 05:27:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67306C04B94A for ; Tue, 4 Jul 2017 09:27:06 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-179.ams2.redhat.com [10.36.117.179]) by smtp.corp.redhat.com (Postfix) with ESMTP id 797591719F; Tue, 4 Jul 2017 09:27:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 67306C04B94A Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=pbonzini@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 67306C04B94A From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 4 Jul 2017 11:27:04 +0200 Message-Id: <20170704092704.8754-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 04 Jul 2017 09:27:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] checkpatch: should not use signal except for SIG_DFL or SIG_IGN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Using signal to establish a signal handler is not portable; on SysV systems, the signal handler would be reset to SIG_DFL after delivery, while BSD preserves the signal handler. Daniel Berrange reported that (to complicate matters further) the signal system call has SysV behavior, but glibc signal() actually calls the sigaction system call to provide BSD behavior. However, using signal() to set a signal's disposition to SIG_DFL or SIG_IGN is portable and is a relatively common occurrence in QEMU source code, so allow that. Signed-off-by: Paolo Bonzini Reviewed-by: Daniel P. Berrange --- scripts/checkpatch.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 45027b9281..73efc927a9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2473,6 +2473,10 @@ sub process { if ($line =3D~ /\b(strto[^kd].*?)\s*\(/) { ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr); } +# recommend sigaction over signal for portability, when establishing a han= dler + if ($line =3D~ /\bsignal\s*\(/ && !($line =3D~ /SIG_(?:IGN|DFL)/)) { + ERROR("use sigaction to establish signal handlers; signal is not portab= le\n" . $herecurr); + } # check for module_init(), use category-specific init macros explicitly pl= ease if ($line =3D~ /^module_init\s*\(/) { ERROR("please use block_init(), type_init() etc. instead of module_init= ()\n" . $herecurr); --=20 2.13.0