From patchwork Mon Mar 11 15:20:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 1910494 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=WqkMW8TR; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=B17Ko485; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=WqkMW8TR; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=B17Ko485; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TtgTF6fPKz1yWm for ; Tue, 12 Mar 2024 02:20:49 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 866053858438 for ; Mon, 11 Mar 2024 15:20:47 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id EACCA3858418 for ; Mon, 11 Mar 2024 15:20:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EACCA3858418 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EACCA3858418 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710170431; cv=none; b=HNrk90hgs+jE3v80eXjVwENB9jeTfGM15hs3Xx8d8bFdz8aCewoxQ/1JPvb3rV3xQFifF934ncfeSLvVlgARR+tgzk7lI/6SUpTAM8O8IR1/qMNmzMZIniuy6Jtxl9C89Gj9FsomRMXpt4dq91eyNtjkG+bBIn0uecZiAAqHHOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710170431; c=relaxed/simple; bh=mXNi1gWcD5kgLiXtUL4EpC9o6oa/aIO3aqHHceXWD6Y=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=se1AHDSX6oOeCV468CuEsczlWdXsw+7xk/1u+hBJsFspU/W+J1W2FHgo54P38OtB7EdAGAipKjiUSnyR9hKUMwUQhbiX2tJg1gC4niG0Ur4I53PIbU+hFVtnGEb/B94ZEhr7qRtUGfZ7Yi3xW/8HUhmYqFgw94VqXUmGlkm9a2A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from hawking.nue2.suse.org (unknown [10.168.4.11]) by smtp-out2.suse.de (Postfix) with ESMTP id 076FE5C8A2 for ; Mon, 11 Mar 2024 15:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1710170429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=HlmhX3A8rHVsfDRjyC2Bn6PfkhpsccgqCniktxKoI/M=; b=WqkMW8TRdvA3spLhTew5GCWRtbr5UKIW19LiVHXGGBvhu4nzrv7W9b/u7KhR8boOjG0BOr BSL5y/VVA4uQqPftuMxZcSy4pPSFXb+wWGcA8WJVEs83WI3+bRuBSFjvQFv+j0OPxVOTN7 +wICaYGJj1t7TP6nDrcZH95Krcbpt3U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1710170429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=HlmhX3A8rHVsfDRjyC2Bn6PfkhpsccgqCniktxKoI/M=; b=B17Ko485q/vs/4g1fWPNV2EiZpNOVNeH+KMj5sEeC3bpTsO0Z++WwHT4i+wWWbxgiYJvrF z8MjoPIApKdY4gCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1710170429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=HlmhX3A8rHVsfDRjyC2Bn6PfkhpsccgqCniktxKoI/M=; b=WqkMW8TRdvA3spLhTew5GCWRtbr5UKIW19LiVHXGGBvhu4nzrv7W9b/u7KhR8boOjG0BOr BSL5y/VVA4uQqPftuMxZcSy4pPSFXb+wWGcA8WJVEs83WI3+bRuBSFjvQFv+j0OPxVOTN7 +wICaYGJj1t7TP6nDrcZH95Krcbpt3U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1710170429; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=HlmhX3A8rHVsfDRjyC2Bn6PfkhpsccgqCniktxKoI/M=; b=B17Ko485q/vs/4g1fWPNV2EiZpNOVNeH+KMj5sEeC3bpTsO0Z++WwHT4i+wWWbxgiYJvrF z8MjoPIApKdY4gCQ== Received: by hawking.nue2.suse.org (Postfix, from userid 17005) id ED4A04A052A; Mon, 11 Mar 2024 16:20:28 +0100 (CET) From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] linux/sigsetops: fix type confusion (bug 31468) X-Yow: Wait.. is this a FUN THING or the END of LIFE in Petticoat Junction?? Date: Mon, 11 Mar 2024 16:20:28 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -4.30 X-Spamd-Result: default: False [-4.30 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.998]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Each mask in the sigset array is a unsigned long, so fix __sigisemptyset to use that instead of int. The __sigword function returns a simple array index, so it can return int instead of unsigned long. --- signal/tst-sigisemptyset.c | 11 +++++++++++ sysdeps/unix/sysv/linux/internal-sigset.h | 8 ++++---- sysdeps/unix/sysv/linux/sigsetops.h | 10 +++++----- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/signal/tst-sigisemptyset.c b/signal/tst-sigisemptyset.c index f5e35e8c22..11e7f39d09 100644 --- a/signal/tst-sigisemptyset.c +++ b/signal/tst-sigisemptyset.c @@ -89,6 +89,17 @@ do_test (void) TEST_COMPARE (sigisemptyset (&set), 1); } + { + sigset_t set; + for (int sig = 1; sig <= NSIG; sig++) + { + sigemptyset (&set); + if (sigaddset (&set, sig) < 0) + continue; + TEST_COMPARE (sigisemptyset (&set), 0); + } + } + return 0; } diff --git a/sysdeps/unix/sysv/linux/internal-sigset.h b/sysdeps/unix/sysv/linux/internal-sigset.h index 3c21c3b6d5..5d7020b42d 100644 --- a/sysdeps/unix/sysv/linux/internal-sigset.h +++ b/sysdeps/unix/sysv/linux/internal-sigset.h @@ -54,7 +54,7 @@ static inline int internal_sigisemptyset (const internal_sigset_t *set) { int cnt = __NSIG_WORDS; - int ret = set->__val[--cnt]; + unsigned long int ret = set->__val[--cnt]; while (ret == 0 && --cnt >= 0) ret = set->__val[cnt]; return ret == 0; @@ -82,7 +82,7 @@ static inline int internal_sigismember (const internal_sigset_t *set, int sig) { unsigned long int mask = __sigmask (sig); - unsigned long int word = __sigword (sig); + int word = __sigword (sig); return set->__val[word] & mask ? 1 : 0; } @@ -90,7 +90,7 @@ static inline void internal_sigaddset (internal_sigset_t *set, int sig) { unsigned long int mask = __sigmask (sig); - unsigned long int word = __sigword (sig); + int word = __sigword (sig); set->__val[word] |= mask; } @@ -98,7 +98,7 @@ static inline void internal_sigdelset (internal_sigset_t *set, int sig) { unsigned long int mask = __sigmask (sig); - unsigned long int word = __sigword (sig); + int word = __sigword (sig); set->__val[word] &= ~mask; } diff --git a/sysdeps/unix/sysv/linux/sigsetops.h b/sysdeps/unix/sysv/linux/sigsetops.h index abd5576172..33db4f77b8 100644 --- a/sysdeps/unix/sysv/linux/sigsetops.h +++ b/sysdeps/unix/sysv/linux/sigsetops.h @@ -28,7 +28,7 @@ (1UL << (((sig) - 1) % ULONG_WIDTH)) /* Return the word index for SIG. */ -static inline unsigned long int +static inline int __sigword (int sig) { return (sig - 1) / ULONG_WIDTH; @@ -66,7 +66,7 @@ static inline int __sigisemptyset (const sigset_t *set) { int cnt = __NSIG_WORDS; - int ret = set->__val[--cnt]; + unsigned long int ret = set->__val[--cnt]; while (ret == 0 && --cnt >= 0) ret = set->__val[cnt]; return ret == 0; @@ -92,7 +92,7 @@ static inline int __sigismember (const sigset_t *set, int sig) { unsigned long int mask = __sigmask (sig); - unsigned long int word = __sigword (sig); + int word = __sigword (sig); return set->__val[word] & mask ? 1 : 0; } @@ -100,7 +100,7 @@ static inline void __sigaddset (sigset_t *set, int sig) { unsigned long int mask = __sigmask (sig); - unsigned long int word = __sigword (sig); + int word = __sigword (sig); set->__val[word] |= mask; } @@ -108,7 +108,7 @@ static inline void __sigdelset (sigset_t *set, int sig) { unsigned long int mask = __sigmask (sig); - unsigned long int word = __sigword (sig); + int word = __sigword (sig); set->__val[word] &= ~mask; }