Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp4037263pxp; Tue, 15 Mar 2022 11:06:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4KjXHDOU1Wz8P1GzjQ+k0x+lweBzquMKC6JPeqtZFGLRqdPzB+PV5H5CrCwA76CGTeBEU X-Received: by 2002:a17:907:7242:b0:6da:b561:d523 with SMTP id ds2-20020a170907724200b006dab561d523mr24035934ejc.118.1647367570068; Tue, 15 Mar 2022 11:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647367570; cv=none; d=google.com; s=arc-20160816; b=EvRhb5iqLX4fdaT+Y1fplMeFnbg28jGiIu6dcfT3MPLQaRmCBK+6Yznl20lLFSqvhe xKjE5EHZYjLaNO5lxvqI241Pat/2TzQIXqgi3To3CsCw53Yn5LERKT6c5wl5hANLGdVh KXMoqCeFzpxbrTkH5DO9eEAFk8J+NE1lp8tjVhk/9EXGK8vVZdia40K12g1ppwE1d5M0 01UGr3iJA6WbV016n43RRFqil+S92UBDIZZhkg9oQhE+N5caheNL5vomZ//Gwv9p3zcQ 9pbr2TVFSbwq/wU3eA8HGSwK0fxUqoaU6QP2D/HDz0vUlt/Jiooa5q7335RQrf6w6M+j /axg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=XANJJRrTumUABT7CugOOw6Zv/rOaUOimqzahBjr1cHw=; b=fYG2tF/oEuoAFrBxg3xnJbLT2jKO68dK3UlzUHpgKWjD2AfIPyb0r4xHt/sXZNZsgz oc0DfmiwGaURzEToMpQNUPqj+vpAl3eBXRS7wkU60JRVNCM0bMyE90JAOW2WnaA4ZUrd x4eLO1NdrgHFIrpXN8fBZ3bGuL2U4We2OEUVFi8BgABqh6p6gaTDn7j5NcPf78DYRjLM Plt7/WF+D6S5aJg+yWw3RjL5y7C3Mz2Y2K5QF01e5OrxVHtN1JitfxDlIZZ29pwQNs+x n5sLzzaZXXdDJvptH+gV+20aWofdfQdsq19U90xO9IHCGMex2lTUqCHqXw1ltaG3dTDl 883A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020a170906171300b006d0eda03ef1si11374822eje.606.2022.03.15.11.05.11; Tue, 15 Mar 2022 11:06:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-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; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237764AbiCNPZY convert rfc822-to-8bit (ORCPT + 99 others); Mon, 14 Mar 2022 11:25:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236583AbiCNPZX (ORCPT ); Mon, 14 Mar 2022 11:25:23 -0400 Received: from mail.holtmann.org (coyote.holtmann.net [212.227.132.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0B05F6354 for ; Mon, 14 Mar 2022 08:24:13 -0700 (PDT) Received: from smtpclient.apple (p5b3d2183.dip0.t-ipconnect.de [91.61.33.131]) by mail.holtmann.org (Postfix) with ESMTPSA id 373DBCECC5; Mon, 14 Mar 2022 16:24:13 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\)) Subject: Re: [PATCH] Bluetooth: fix incorrect nonblock bitmask in bt_sock_wait_ready() From: Marcel Holtmann In-Reply-To: Date: Mon, 14 Mar 2022 16:24:12 +0100 Cc: Johan Hedberg , Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20220224100641.2449550-1-gavin@matician.com> <71D25C8F-67D1-4EC0-9160-5F61C832F0AF@holtmann.org> To: Gavin Li X-Mailer: Apple Mail (2.3693.60.0.1.1) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Gavin, >>> diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c >>> index ee319779781e6..69374321130e4 100644 >>> --- a/net/bluetooth/af_bluetooth.c >>> +++ b/net/bluetooth/af_bluetooth.c >>> @@ -568,7 +568,7 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo) >>> EXPORT_SYMBOL(bt_sock_wait_state); >>> >>> /* This function expects the sk lock to be held when called */ >>> -int bt_sock_wait_ready(struct sock *sk, unsigned long flags) >>> +int bt_sock_wait_ready(struct sock *sk, unsigned int flags) >> >> can we then also do s/flags/msg_flags/ then. > I prefer keeping it as flags because all other net code also uses > flags, msg_flags only appears > in msg->msg_flags. while that might be true, I find it a lot clearer if the variable is msg_flags. >>> @@ -576,7 +576,7 @@ int bt_sock_wait_ready(struct sock *sk, unsigned long flags) >>> >>> BT_DBG("sk %p", sk); >>> >>> - timeo = sock_sndtimeo(sk, flags & O_NONBLOCK); >>> + timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); >> >> Since sock_sndtimeo() is taking a bool. This might be better !!(flags & MSG_DONTWAIT). > It appears to be well-known in the net code that sock_sndtimeo takes a > bool, since no other > uses of it do the "!!" conversion. > > Let me know what you think. I can make the changes if needed but I was > just trying my best > to match the currently existing convention. And other code in the kernel makes sure to clearly turn something into a bool. You get 0x00 and 0x40. Regards Marcel