Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp676164ybk; Wed, 20 May 2020 09:11:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHnCgLvvn75vGkb2ns0OIhWyZpH7MS5m5k7QLgt03TqiY+OK9I5XzH1QE5bshTgxf3D3xH X-Received: by 2002:a05:6402:1547:: with SMTP id p7mr3983185edx.31.1589991092153; Wed, 20 May 2020 09:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589991092; cv=none; d=google.com; s=arc-20160816; b=u0FCjeZo3s0lGOQzc5K8ZVCMDY8FfWkrrIA8ffEhkZQP9lpIowu+Jcc6m6CBFvF7js ycaS+t19+KlFYyYMc6UWQe/BfxfL6fLPN2S4FyaGRgV2f8Q7QagZY+kwE1OL6i7lwqIO RKoOPh2u+u4NcIczyuQimyyAMiVuiIPehe9VbftppQN/iap4GhP7uRn2QuoQAQQDHzTX EvF9E6guxx8UTTIMCaHODfoXImmI1MzXH1XC7uVR+WxIC2RZ/dHPi4gJUTIYN2zLt5OQ hyQXVNKipI+W4VtN15lear5zQbgjc0Cd4V98EVX0NmAdqLZIwTINrFcrKTK5h7q2fsoi mhNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=b0xYWh+w/F4qTSH0QTclL7MS2e+5mKVzQgF0NwX1VdA=; b=wu0rTdciKWW10dT2RxslK/h6zVJGoXSbssRyTpV+H/ivgBM/ZI/AH/a8LlCNLIcNbS W7l9O6l0Ko2N19+m1xVbfzgm28K2P7FxSZNbM60/nC2V40jgpAwcJ1XjPL4btWexyIxq E+npNVvEANWf/DMJQRc99fXQxoab0vV3AHsnf6JW91IYQko0B6CAN1Y5usjw8BtAGyjZ cTM7YE864PFYKnYddbDnKlc10D+ML6VNbQ/mUAnVxXG1cNT7puJXsJI02N0vNDIPq47g kh66bCtTdQqgp3IqwsxFEwNy0Vs72yhx3uhxIyzPDy+YC2GHKythMVbgLpejhCKHDsRP WEEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xbrxSUuT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt27si1377391edb.94.2020.05.20.09.11.09; Wed, 20 May 2020 09:11:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xbrxSUuT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726936AbgETQIv (ORCPT + 99 others); Wed, 20 May 2020 12:08:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgETQIv (ORCPT ); Wed, 20 May 2020 12:08:51 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F22CEC061A0E for ; Wed, 20 May 2020 09:08:50 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id j5so3761572wrq.2 for ; Wed, 20 May 2020 09:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=b0xYWh+w/F4qTSH0QTclL7MS2e+5mKVzQgF0NwX1VdA=; b=xbrxSUuTV4VsNXGHpyNiBREQh4CjaWtB9BN3dY9RtRsbQ3q6Wc1c9zuirNc4ZD5/nT Na+uOjpDr1J/5SJkZVH7w3a/7jxWGFfeFYXRkQlbsJuSC+swTEBM7Mihk9eJ9vk8eE1F rmg5VkyVcsfs5z09UB0WfHUjghVCddAtVvIF73rqjLcOJB0vkmJ/hNqUIM5K9bHYtYB2 Qk4fB9WSOL3xDfNiYR6N7lAnv/yv1Jpgq+z/7mRt5cEmMc9CjeaaX+kHeO8sPiXuI/BX XKbg13F2pI5vgTw1ZgCCUDSxyFh3ptYp3UEMYTYaVhykHgrjuTAfikxoac2kbplmLjth OYDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=b0xYWh+w/F4qTSH0QTclL7MS2e+5mKVzQgF0NwX1VdA=; b=Kdc8jqbsv0+yqtN5UaPWHIxXb53lFuoIHQfZrAahf7tEVNy4VLnE46B3OVvCSkdNfj HGscsKdo9Y7kb+OJce65NjwG4JKnkiI53bVyCGwA2OnpArRnyvooRrvtXGxyzeyXHOsU CZOdmSO1pjzultxOu2vRI/oq0LVzJyhzIlYcK5gbcbQ3T2rfq1jzsKLPLZgUTKQYDnc/ zQ1bie+ehwswf+QFVZajb0bPnnfyf1c64dOvEDhk22U00M8GnyHnFNYwLlYi6yxPVCeQ OuyIfyYMCSvkufbEMdkNfQDyYubbCowdT1BcQst5iP55/rfCIuXoLsTZUybYAPmLGI2E 6Ctw== X-Gm-Message-State: AOAM533QhFGDo+cBUoj5Ts82InEeoIa7Z7E01LWb4sKMaecYLweJgri6 o6CGIs2SaZctl4mqzToYv4hQzQ== X-Received: by 2002:a5d:5751:: with SMTP id q17mr4842701wrw.106.1589990929733; Wed, 20 May 2020 09:08:49 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id z11sm3297731wro.48.2020.05.20.09.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 09:08:49 -0700 (PDT) Date: Wed, 20 May 2020 17:08:47 +0100 From: Daniel Thompson To: Douglas Anderson Cc: Jason Wessel , sumit.garg@linaro.org, Chuhong Yuan , Dan Carpenter , Masahiro Yamada , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kdb: Cleanup math with KDB_CMD_HISTORY_COUNT Message-ID: <20200520160847.dpvut45zjd5msz6w@holly.lan> References: <20200507161125.1.I2cce9ac66e141230c3644b8174b6c15d4e769232@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200507161125.1.I2cce9ac66e141230c3644b8174b6c15d4e769232@changeid> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 07, 2020 at 04:11:46PM -0700, Douglas Anderson wrote: > From code inspection the math in handle_ctrl_cmd() looks super sketchy > because it subjects -1 from cmdptr and then does a "% > KDB_CMD_HISTORY_COUNT". It turns out that this code works because > "cmdptr" is unsigned and KDB_CMD_HISTORY_COUNT is a nice power of 2. > Let's make this a little less sketchy. > > This patch should be a no-op. > > Signed-off-by: Douglas Anderson Applied, thanks!