Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5660322rwi; Sun, 23 Oct 2022 09:38:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5vl4ICGr2mEgNtTV5f29dzRnD5fKTEQmEYIGzGTc/DrBJlea3cIh+7tPfcA8yY5Ql4R4d7 X-Received: by 2002:a17:906:9b86:b0:73d:72cf:72af with SMTP id dd6-20020a1709069b8600b0073d72cf72afmr23863471ejc.440.1666543118856; Sun, 23 Oct 2022 09:38:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666543118; cv=none; d=google.com; s=arc-20160816; b=tz5wR8nhcCzN6DEtsF4a2Xqqbxcgeosk1G38oAM2+gsOXwrxYeYb6V2xyEQ37i5ZsR WpjEpTPlE6aF/Xq+jH5v49ALVKv9q3wwvCsTpSSIXTzlM/B4O6NyDWbyAw7g+J1xd2kw oSoEOjYfJnqHCEA0szOTAWQ7RkcMC2DTcygz2xmlm+Oml2cMei82G7okkd4bzcR3MlZJ Koey89JheW4YPgG4qCAQ6AWYu0wUy2lhPceGIlxzYmNhQ+6ErkR0cECevC/P4F5H4kAu x2fhyVVrihyy2XaDXU7zXap9G6bWdA+50tSCi9e89rayGWLOut94mUjD3++Zl0pU+urY IG5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CSZwJUxgIn3bKtgAKKjT016s8W+MLEV9NZDL27jQvF4=; b=zwQS6BRK415PrXTeqeVdAkGC6ubHIM4LOUklAK23Y8UsNalsRJa8o1woPwQk/8j3cq C7ohCfEKdjB6URd8ykH7pWGmFieDxlOUv8Tjd2Xx0zc8MoWxj9QFW4zS+TVAR1wZ1DhZ N+m8NipiVucpr5pChPeOZF/fMSRFK/RWKMKP8Nrl+Bm+jcnYi7YCXLaAK4yXeCGXBV+H JosZ/o4O1QnpVVT20Ii7+KNLLKvZ20G1HuFZUwSPymdUVzM3smigzYjK1Es5aMIUmI4o EZhIa7x9HChjLN9YaxQy3ojreO6EA8IoK3kPTgkiHQ/7Pbk8iN6u0ubDAadHKqKpI8xU H+8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jP1bTPF1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg15-20020a170907a40f00b007897abd2d17si19693281ejc.468.2022.10.23.09.38.12; Sun, 23 Oct 2022 09:38:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jP1bTPF1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230289AbiJWQEc (ORCPT + 99 others); Sun, 23 Oct 2022 12:04:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230027AbiJWQEa (ORCPT ); Sun, 23 Oct 2022 12:04:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5F3EB4BD; Sun, 23 Oct 2022 09:04:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 82747B80D4F; Sun, 23 Oct 2022 16:04:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90271C433C1; Sun, 23 Oct 2022 16:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666541066; bh=hH28WnDvFDE2qfWdV6HVPtVEhC+usBQqGVk2hARPGUA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jP1bTPF1VXIqGUgmuH7MRHbmOyGLatP3s7xtbkaKandIC3ZjDqehXjVJHMGerF4LO kNF2UoMxmtBeg0Flktjsb+B3OB8kufqYsBa95EoH/hWsXTPOFUDijEPdvkvHCZgTY7 fxDWCwaguqGmQAXEVhTXmAJD40BYJvdD05aMPqe4= Date: Sun, 23 Oct 2022 18:04:22 +0200 From: Greg Kroah-Hartman To: Linus Torvalds , Alan Stern Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi , Jakob Koschel , Randy Dunlap , Ira Weiny Subject: Re: [PATCH] USB: gadget: dummy_hcd: switch char * to u8 * Message-ID: References: <20221021064453.3341050-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 23, 2022 at 05:53:19PM +0200, Greg Kroah-Hartman wrote: > On Fri, Oct 21, 2022 at 10:30:37AM -0700, Linus Torvalds wrote: > > On Thu, Oct 20, 2022 at 11:44 PM Greg Kroah-Hartman > > wrote: > > > > > > The function handle_control_request() casts the urb buffer to a char *, > > > and then treats it like a unsigned char buffer when assigning data to > > > it. On some architectures, "char" is really signed, so let's just > > > properly set this pointer to a u8 to take away any potential problems as > > > that's what is really wanted here. > > > > I think you might as well also remove the cast that was always a bit odd: > > > > buf[0] = (u8)dum->devstatus; > > > > although maybe it's intentional ("look, ma, I'm truncating this > > value") because 'devstatus' is a 'u16' type? > > (adding Alan as he's the owner of this file now) > > Yes, devstatus is a u16 as that's what the USB spec says it should be, > but so far only 7 of the lower bits have been used. I guess to do this > properly we should also copy the upper 8 bits in to buf[1], eventhough > in reality it's only ever going to be 0x00 for now. Along these lines, do we really not have a predefined macro/inline function that does: (value >> 8) to give you the "high byte" of a 16bit value? I keep seeing people write their own macros for this in staging drivers, but I just attributed that to them not using the correct in-kernel macro, but I can't seem to find anything at the moment to do this (same with "give me just the lower 8 bits of a 16bit value"). Am I just blind? It's not like it's complex or tricky stuff, I just thought we had something in bits.h or bitops.h or the like. Oh well... thanks, greg k-h