From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BDA7C3858CD1 for ; Mon, 20 Nov 2023 20:08:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BDA7C3858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BDA7C3858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700510931; cv=none; b=RvJzZdSlSL+iudj/F353aldTE5FDRSN9Mx2cwrQdNI/uCWAeAMagGIGsLGoVyfgd1gDZfd5F4AMgpmwQWUv21kG/DWwbs3CZOcRJ1AwVGRvafPp/WVUKrJoqsv9VJCM3NHm0qnZ5yN4Up8AQ2KDgLnKokVT+Y4ex6x1WWBM4HGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700510931; c=relaxed/simple; bh=yHzxWoClwc9/bqvEkjInmv/FE6yWEDy0AgGuvpMgclw=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=O84ZcvM03P3F1S8FWIP+i2Bw3ygDKXSbGGPeZ7PzGTST82SfP2q1OT5eOxSG7jP/zugu6Iz3lxxyckjk/H65SY2DzX/MaQztUmiAL81WlXETbRHgRGJiWgiGOed/qlJ2s5gXWomgtzK4i8jBCh1Bg6G6T0W8hnP1xyDoHZLM8NQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700510930; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=ll3jW/lPiNWtRGXdTthewrVOPn7/Hr36+b/uJumHJts=; b=Sp6jdJvr8KGxrYzmGrwvgAHYCkNgylRpgif2g28tvbdtJbKNk5FHHx/hy83X3YRqqOBDv5 1YrJ+Ngs7vbbA2fXTdAGe8ec2Z2g6rz1P23iMmhgq3ae/3VvqSu2BMHXlOTOtSxWSACief 2xpZpfLV4EETjOoBZBICl9/I2z/v1kE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-639-onuo3i1lOGONgILcEPJl3g-1; Mon, 20 Nov 2023 15:08:49 -0500 X-MC-Unique: onuo3i1lOGONgILcEPJl3g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id E267F811E7E for ; Mon, 20 Nov 2023 20:08:48 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.193.251]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C10812026D4C for ; Mon, 20 Nov 2023 20:08:48 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 758A7A809BE; Mon, 20 Nov 2023 21:08:46 +0100 (CET) Date: Mon, 20 Nov 2023 21:08:46 +0100 From: Corinna Vinschen To: newlib@sourceware.org Subject: Re: [PATCH v2] newlib: libc: Fix bugs in the commit 3d94e07c49b5. Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: newlib@sourceware.org References: <20231110160947.1518-1-takashi.yano@nifty.ne.jp> <20231116212723.45c488a9177ab05b922ee901@nifty.ne.jp> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 List-Id: On Nov 16 15:08, Corinna Vinschen wrote: > On Nov 16 14:48, Corinna Vinschen wrote: > > On Nov 16 14:19, Corinna Vinschen wrote: > > > On Nov 16 21:27, Takashi Yano wrote: > > > > 2) __swbuf_r() has ORIENT (fp, -1) call, however, result is not checked. > > > > > > Good catch. Looks like setting the orientation at this point is > > > wrong. __swbuf_r is called via the __sputc_r macro in stdio.h. > > > But __sputc_r is also called from __fputwc as well as, potentially, > > > from _fputws_r. > > > > > > AFAICS, we already set the orientation from the calling functions > > > _putc_r (covering putchar, putc, fputc) and from _puts_r as > > > well as _fputs_r (covering puts, fputs). > > > > > > On the wide-char side, we set the orientation from _fputwc_r > > > (covering putwchar, putwc, fputwc) and from _fputws_r (covering > > > fputws). > > > > > > So I *think* we can safely remove the ORIENT call from __swbuf_r, > > > or did I miss some other way to call __swbuf_r? > > > > Yes, I did. The _getchar_unlocked and _putchar_unlocked macros as well > > as the __SINGLE_THREAD__ getc and putc macros(*). I also missed the > > putc{har}_unlocked and getc{har}_unlocked functions. > > > > They all call __sgetc_r or __sputs_r, both being macros in stdio.h. > > The underlying functions __srget_r and __swbuf_r are shared between > > byte and wide-char orientation functions. > > > > Drat. Looks like we really have to do the ORIENT stuff inside the > > __sgetc_r/__sputs_r macros... > > That's not feasible. The only way out as I see it is that we don't > share the underlying functions and macros between byte and wide-char > functions: > > - _fputwc_r and _fputws_r must not call __sputc_r from stdio.h, they > should get their own version. > > - The underlying functions __srget_r and __swbuf_r have to be split into > two functions each, or they have to get an additional parameter > deciding how to set the orientation. > > - In turn, we can remove most of the ORIENT calls in the calling functions. I applied matching patches. After checking the code for as couple of hours I'm pretty sure __srget_r doesn't have to be split because all wide-char oriented functions call __srefill_r directly. I seriously hope I didn't miss anything. Feedback appreciated. Thanks, Corinna