Message ID | 5155a6bb36800aa1a8bdb214f59f85f9d92b6989.1666192979.git.aburgess@redhat.com |
---|---|
State | Committed |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5F6538560A9 for <patchwork@sourceware.org>; Wed, 19 Oct 2022 15:28:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5F6538560A9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666193292; bh=9UtDGilkQltRfWFRUUzhjVVD4XRvpTIpMci0RF7Sf+w=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ZSigzM30MmjSoEInQNg4rz3sTtmwon2Z+jmVMdf9UGmU5fWijUJXrvAFsz2Pegyo7 R2Ot4T0rK2kGWdyMd0OjGhCPwTocIU38pYSK71ChpaIvJNYR++UBsK5xRAKCqIhzmr Fsm1VZnBha76L/Cgz5PnqZEskdrNdezV35n+HOMg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 52E733850862 for <gdb-patches@sourceware.org>; Wed, 19 Oct 2022 15:25:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 52E733850862 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-478-6rpgTgsoMDqLE1VfX43Gzw-1; Wed, 19 Oct 2022 11:25:03 -0400 X-MC-Unique: 6rpgTgsoMDqLE1VfX43Gzw-1 Received: by mail-qt1-f199.google.com with SMTP id d1-20020ac80601000000b00388b0fc84beso12996632qth.3 for <gdb-patches@sourceware.org>; Wed, 19 Oct 2022 08:25:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9UtDGilkQltRfWFRUUzhjVVD4XRvpTIpMci0RF7Sf+w=; b=nCNM9tTnN3HtrhJjxtyehhX6BJIhEValyVPHdeZv342bJ4CkWcekUK9H6zrPyKTZjd dCQuo+Fqaz67e8F3C7v8x3rQ9OwWgKesqulwE3rAqpPQwbkTJL/P+NSyAkrOaYj6Ps8X TzAxw6MnjzcKXuOsuy+GcWP8LIT37LtU6HiysYoS0AxaI4hq+3nFqjrL8yJFOlK2zLn/ yiS8d4JnN265W0ddvzx5t9l7OIuZpd62JJfetVJOvKHyt8bKnwRLbsCJF3AU+HJ/ipaq kAf7I8CgLHuwkAmJEjxFoeGuij9lfyVVodk+lFcswpKS4H84lieEpAbL7HbA4CdG23y6 79Vw== X-Gm-Message-State: ACrzQf3UWV4KWfU7mBrxp4QhcOnK//BljbEsr1eM3pFNHcmaU9SjqoKU /95vVAaVz45elsQYo/B6Gc+oKIGfIoSkJmFouHNyYe8vcCeQbVd/wKdxi8s6DSK1iSR3obaw/QJ KnxRcsbU57p3GBgEMyepNOj28r5fw+9KlnEJ4r+a4K3wDYQ62A9GtIhnYSseBXMqb0aG7DtiMyQ == X-Received: by 2002:a05:622a:206:b0:39c:f2cf:f9fa with SMTP id b6-20020a05622a020600b0039cf2cff9famr7031442qtx.669.1666193102783; Wed, 19 Oct 2022 08:25:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7T+z+q/RQdrchsWblUiJJLxIxbAerrhbo9EvI5Cny03pOfa9R+YklJW2ZC7vRODKrk0Y8tVg== X-Received: by 2002:a05:622a:206:b0:39c:f2cf:f9fa with SMTP id b6-20020a05622a020600b0039cf2cff9famr7031419qtx.669.1666193102503; Wed, 19 Oct 2022 08:25:02 -0700 (PDT) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id t12-20020ac8588c000000b0039cd4d87aacsm4314013qta.15.2022.10.19.08.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 08:25:02 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 04/10] sim/ppc: don't pass uninitialized value to semctl for GETVAL calls Date: Wed, 19 Oct 2022 16:24:43 +0100 Message-Id: <5155a6bb36800aa1a8bdb214f59f85f9d92b6989.1666192979.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <cover.1666192979.git.aburgess@redhat.com> References: <cover.1666192979.git.aburgess@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Andrew Burgess <aburgess@redhat.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Building the sim/ tree with clang
|
|
Commit Message
Andrew Burgess
Oct. 19, 2022, 3:24 p.m. UTC
When calling semctl with an GETVAL action, the 'union semun' argument is unused. Rather than passing an uninitialized variable (as we currently do), just pass the integer 0. This silences some compiler warnings, and is just as correct (given the argument is ignored). To be honest, it might be the case that the argument is not needed at all, however, I'm a little nervous to make this change as the amount of testing I can do of this code is limited. Every example I found online for a semctl/GETVAL call did pass the final argument, so that's what I've continued to do. --- sim/ppc/hw_sem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 19 Oct 2022 16:24, Andrew Burgess via Gdb-patches wrote: > When calling semctl with an GETVAL action, the 'union semun' argument > is unused. > > Rather than passing an uninitialized variable (as we currently do), > just pass the integer 0. This silences some compiler warnings, and is > just as correct (given the argument is ignored). > > To be honest, it might be the case that the argument is not needed at > all, however, I'm a little nervous to make this change as the amount > of testing I can do of this code is limited. Every example I found > online for a semctl/GETVAL call did pass the final argument, so that's > what I've continued to do. the semctl prototype is: int semctl(int semid, int semnum, int cmd, ...); i would just delete the 4th arg, but if you really want to keep the 0, OK. -mike
diff --git a/sim/ppc/hw_sem.c b/sim/ppc/hw_sem.c index 937e2ad6f81..78e3dda9ae6 100644 --- a/sim/ppc/hw_sem.c +++ b/sim/ppc/hw_sem.c @@ -148,7 +148,7 @@ hw_sem_init_data(device *me) error("hw_sem_init_data() semget failed\n"); } - sem->count = semctl( sem->id, 0, GETVAL, help ); + sem->count = semctl( sem->id, 0, GETVAL, 0 ); if (sem->count == -1) error("hw_sem_init_data() semctl -- get value failed\n"); DTRACE(sem, ("semaphore OS value (%d)\n", sem->count) ); @@ -241,7 +241,7 @@ hw_sem_io_read_buffer(device *me, } /* assume target is big endian */ - u32 = H2T_4(semctl( sem->id, 0, GETVAL, help )); + u32 = H2T_4(semctl( sem->id, 0, GETVAL, 0 )); DTRACE(sem, ("semaphore OS value (%d)\n", u32) ); if (u32 == 0xffffffff) {