From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 72E7D384F035 for ; Wed, 5 May 2021 18:53:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 72E7D384F035 Received: from vapier (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 84660340E8B; Wed, 5 May 2021 18:52:59 +0000 (UTC) Date: Wed, 5 May 2021 14:52:58 -0400 From: Mike Frysinger To: Tom Tromey Cc: Mike Frysinger via Gdb-patches Subject: Re: [PATCH/committed] sim: rl78: clean up various warnings Message-ID: Mail-Followup-To: Tom Tromey , Mike Frysinger via Gdb-patches References: <20210505030449.25159-1-vapier@gentoo.org> <87k0odqe9w.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87k0odqe9w.fsf@tromey.com> X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Wed, 05 May 2021 18:53:01 -0000 On 05 May 2021 11:30, Tom Tromey wrote: > >>>>> "Mike" == Mike Frysinger via Gdb-patches writes: > > Mike> Fix a logic error when processing commands where p was reassigned > Mike> to cmd and then has its leading whitespace scanned a 2nd time. > Mike> Handle short reads with fread(). > > Mike> - /* Find the extent of the command word. */ > Mike> - for (p = cmd; *p; p++) > Mike> - if (isspace (*p)) > Mike> - break; > Mike> - > > I'm not sure it makes sense to completely delete this. > Perhaps instead just removing 'p = cmd' is correct? > > It looks to me that this code is trying to parse a command name followed > by arguments. Like, ideally, "monitor trace on" should set cmd="trace" > and args="on", but with the patch I don't think this will happen. you're right that the code is more subtle than i thought. but it's still broken with that tweak. it's broken today too. pretty sure this code has always been wrong and crashes, either from writing to read-only memory, or trying to free an invalid pointer. it basically needs to be gutted. glancing at some other ports (m32c & rx), they have the same bugs, so looks like it started with one bad form, and then copied around. i think replacing it with buildargv is easiest. -mike