From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +OrvBBsygGEzcwAAWB0awg (envelope-from ) for ; Mon, 01 Nov 2021 14:29:47 -0400 Received: by simark.ca (Postfix, from userid 112) id 01CA91F0BB; Mon, 1 Nov 2021 14:29:46 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5A1311E813 for ; Mon, 1 Nov 2021 14:29:46 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8B21B3858004 for ; Mon, 1 Nov 2021 18:29:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B21B3858004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1635791385; bh=W+1dKZr9edADlxG52fQJ3Fy1hQN7isHCsIFUSnNarDY=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=dyFdETBM7PMGj7Y9b9OJcbs2IuGHEgFldArKdsHCTKq/AownoLlyO+Fqu8PS3gV4K xn9SKdVbez4LfE+e9jUHvULzaMxjx3xtGTntI5dkGTdhsUkaza9aK+p5dNt50p8VTM uD+z7hL7mwjjIU3H8Mvp7XaLCCxY3I1mHNUztwUk= Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by sourceware.org (Postfix) with ESMTPS id E29BB3858403 for ; Mon, 1 Nov 2021 18:29:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E29BB3858403 Received: by mail-qv1-xf2b.google.com with SMTP id u25so11821333qve.2 for ; Mon, 01 Nov 2021 11:29:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=W+1dKZr9edADlxG52fQJ3Fy1hQN7isHCsIFUSnNarDY=; b=Q1IUBvpbWCpnGRi15VvfyxZRde9Ib23yK8zCX4Q0jvT6OPa7z+5Zn5jMIvuyLMTvzs cBoDZSz6i8TbK/mwJjjQgtgGcE1bdSO1tc4w+FdUjPQnkQDOfi4LYbR4ujPO5f9s0Fhz LBF2tx0PUKw3+hNQErg4/VhvODdBV2TpkcKGPbXd2+GujquAdstm09n+ZzHeBaxwWXFF qbHoacC3AmT1fxyg6LBE468mMPDLrSfesuhYohuU82YwGmlpcoPi0r6Xw9KLfUY7woOK 1xYFQmPpem6XXgZXyMHHWeAajoxP25ldyqCn8X0jvCa39Qp44e02wUJPPbSi5NPgw7Cg VTBw== X-Gm-Message-State: AOAM5323iCtkYTP83j9nx4wOkibZpfj622Nf6L9YbwfUCXoSezfyPz3G XGWpwr3ZzzL9QJNjXBcaj9cdkESEQuTZkaG3U43rpLcDUVA= X-Google-Smtp-Source: ABdhPJz/vfhaMMBPN34dLI8cDpGxCg9UEQS0mVpFh6sl6y7a8YwqSBHuAQ1KVPkdZMMOtK38RgRNfh7HzN5W4DpWIF4= X-Received: by 2002:a05:6214:224d:: with SMTP id c13mr30412899qvc.37.1635791366233; Mon, 01 Nov 2021 11:29:26 -0700 (PDT) MIME-Version: 1.0 References: <20211101034519.29154-1-vapier@gentoo.org> In-Reply-To: Date: Mon, 1 Nov 2021 14:28:48 -0400 Message-ID: Subject: Re: [PATCH] sim: mn10300: clean up pointer casts To: Christian Biesinger , gdb-patches Content-Type: text/plain; charset="UTF-8" X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Christian Biesinger via Gdb-patches Reply-To: Christian Biesinger Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On Mon, Nov 1, 2021 at 12:22 PM Mike Frysinger wrote: > > On 01 Nov 2021 12:07, Christian Biesinger wrote: > > On Sun, Oct 31, 2021 at 11:45 PM Mike Frysinger via Gdb-patches > > wrote: > > > --- a/sim/mn10300/dv-mn103ser.c > > > +++ b/sim/mn10300/dv-mn103ser.c > > > @@ -238,7 +238,7 @@ do_polling_event (struct hw *me, > > > { > > > SIM_DESC sd = hw_system (me); > > > struct mn103ser *serial = hw_data(me); > > > - long serial_reg = (long) data; > > > + long serial_reg = (uintptr_t) data; > > > > Shouldn't you change the variable type too? > > the types are already confused, but long here is fine as any other. uintptr_t > is not really any more correct. serial_reg comes in as an unsigned_word via > the memory read/write callbacks, (encoded) cast to void*, and (decoded) cast > to long. the memory read/write callbacks verify the values are always within > the serial_register_types enum range which looks like [0,16] range, so any of > these types work. > > > Otherwise this patch seems to be somewhat pointless? > > if ( nr_bytes == 1 ) > > i don't know which one you mean, or why you think any of them are pointless. > the nr_bytes checks are in the read/write code paths of the memory mapped > register callbacks. so nr_bytes is needed & correct there. I forgot to delete that nr_bytes line; the pointless comment was about casting to uintprtr_t but still storing the result in a long. Why not keep it as a cast to long then? Christian