Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2985ybg; Tue, 2 Jun 2020 14:34:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2XzhRU1RVgcEKHdjFTX2pclZp8iBjoYC5FfphqCvylrlPKWA2WvhXOcyMf8T6deovEWxu X-Received: by 2002:a17:906:2a4d:: with SMTP id k13mr26196565eje.253.1591133694947; Tue, 02 Jun 2020 14:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591133694; cv=none; d=google.com; s=arc-20160816; b=CsL1rZuNW9wF1gmWs9FhdiNqvB4r7lUM3bqugbE9OahuCwSJ1grL3ZZ5x5p97CNXvF T0vAeEIX2K+/XzMgTftAAvO9O5t93MXvdbqggg6TbLJICrD3JiDk0751d9mcDX9s52ik HDfYDwrKRcYhnJudIXkrjjPckGBMR5Ay32mtApiV1IS6Yxn5z6tRCfX4vuMal5X9Pcu4 bRUkSzXfhgUK2HBKsa4A5sff1LWSTPdkEZVE/bgK6UdbHSKV11kgLyy5703AQJTK4q4H +/LXimfmqHUnI8VQ35++2fysiMYUkJysxWlUdRxO0A0jcMJtX9sr7cc99CQ2xtFOnS9e McHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=m9kn62PqAX47M9GdWLUtWEHWFrrXZP2eF+NQ55cvCow=; b=vyoI+jIrg1wNxvsHxS+50heU5nnFEkF0agWYt0K7FY7+djeXIHoV1gCJvFdz8oSRCL VArrDfLB2lMawgMeKSa1eB3iN2RPuN9J5oL3lj9HaQe0vT+dY3jp3Lwn7+y35h/rQ1A3 D+6sEsLjMUKcXlS0QJWiQHAcgLkqzivRXwly2VhHuckByv6T68PU5F+bw+Fgcf9oGtZw YEe7E241FwHJ/c8ODd0EOGaMKOqfDR6HA5IYJ5LW7qHVG6krTvpttgNtAIDiNKsRWTrm mZLIPt6U34/6XRGjiKvYDZSK1oOCI4mqiTR3Yyt4p/06dNHWvlLG7RJUr9w14cJTtycq I2Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SDLDlNa2; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ly19si64593ejb.394.2020.06.02.14.34.29; Tue, 02 Jun 2020 14:34:54 -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=@chromium.org header.s=google header.b=SDLDlNa2; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726420AbgFBVcT (ORCPT + 99 others); Tue, 2 Jun 2020 17:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgFBVcS (ORCPT ); Tue, 2 Jun 2020 17:32:18 -0400 Received: from mail-vs1-xe44.google.com (mail-vs1-xe44.google.com [IPv6:2607:f8b0:4864:20::e44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62EE1C08C5C0 for ; Tue, 2 Jun 2020 14:32:18 -0700 (PDT) Received: by mail-vs1-xe44.google.com with SMTP id 1so141007vsl.9 for ; Tue, 02 Jun 2020 14:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m9kn62PqAX47M9GdWLUtWEHWFrrXZP2eF+NQ55cvCow=; b=SDLDlNa2JxAHtTUthkbE/nmVRXVihXNqZOfFZYLWMG5r+lFumi+7JFsdsehrTevXOO sCMLupns01dIukJUzu+RAzsGgJTsGMJ0hdFyNazYDLeWHUCALEfmotGmMzlzrMCgn33I Ur8gkspMU96YkoSIkFWxipJQ6pyHI+/nTKxZ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m9kn62PqAX47M9GdWLUtWEHWFrrXZP2eF+NQ55cvCow=; b=Lc0tztg4CS/vgLLelEp4flNK5QHtbrh2fww1co+S4UIHBtB0K7p8znOVxOdT48OgLx 4uOFpod3/cmk+xfg21PYnDMgIzyk7mIQGXX8cLMiDgP0MbXr55dRznUDqfC71C3d83ZH Arc7rX1PQC65eKE490Hmjkm620Z0Z2aLPCeK4kAs+AnM/LSYpFikW9Q9RnELXoTVQmGj K6ki7j+D/5t+a+WGwSYDcd3PLdnhGKzeDMc1gZslLvpSjgsSuJTg8Qenw+JpN+Ycr8bK 773buOQyA2HnFtzlb0J7lrdiSamvAiNVlNUX2AVfgKpwjTQEd6YpRnuRjxn6+Dzj59Xy sHNg== X-Gm-Message-State: AOAM532Wa2j0LYmi9wZ9CoQOUo0n+irUThPOtre2XIBmISoJ4gm/fciD 3c2TZkS/sJZ4ByfT6+MkJ9QQOeMd/8c= X-Received: by 2002:a67:db81:: with SMTP id f1mr13470920vsk.81.1591133536883; Tue, 02 Jun 2020 14:32:16 -0700 (PDT) Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com. [209.85.222.43]) by smtp.gmail.com with ESMTPSA id k68sm6773vsc.32.2020.06.02.14.32.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Jun 2020 14:32:15 -0700 (PDT) Received: by mail-ua1-f43.google.com with SMTP id 59so121306uam.7 for ; Tue, 02 Jun 2020 14:32:15 -0700 (PDT) X-Received: by 2002:ab0:1684:: with SMTP id e4mr18561066uaf.22.1591133535074; Tue, 02 Jun 2020 14:32:15 -0700 (PDT) MIME-Version: 1.0 References: <1590751607-29676-1-git-send-email-sumit.garg@linaro.org> <1590751607-29676-2-git-send-email-sumit.garg@linaro.org> In-Reply-To: <1590751607-29676-2-git-send-email-sumit.garg@linaro.org> From: Doug Anderson Date: Tue, 2 Jun 2020 14:32:03 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 1/4] kdb: Re-factor kdb_printf() message write code To: Sumit Garg Cc: Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, Jason Wessel , Petr Mladek , Sergey Senozhatsky , Greg Kroah-Hartman , Jiri Slaby , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, May 29, 2020 at 4:27 AM Sumit Garg wrote: > > Re-factor kdb_printf() message write code in order to avoid duplication > of code and thereby increase readability. > > Signed-off-by: Sumit Garg > --- > kernel/debug/kdb/kdb_io.c | 61 +++++++++++++++++++++++++---------------------- > 1 file changed, 32 insertions(+), 29 deletions(-) > > diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c > index 924bc92..e46f33e 100644 > --- a/kernel/debug/kdb/kdb_io.c > +++ b/kernel/debug/kdb/kdb_io.c > @@ -542,6 +542,33 @@ static int kdb_search_string(char *searched, char *searchfor) > return 0; > } > > +static void kdb_io_write(char *cp, int len) nit: "const char *" just to make it obvious that we don't modify the string? > +{ > + if (len == 0) > + return; Remove the above check. It's double-overkill. Not only did you just check in kdb_msg_write() but also the while loop below will do a "no-op" just fine even without your check. > + > + while (len--) { > + dbg_io_ops->write_char(*cp); > + cp++; > + } > +} > + > +static void kdb_msg_write(char *msg, int msg_len) nit: "const char *" just to make it obvious that we don't modify the string? Other than those small things, this looks nice to me. Feel free to add my Reviewed-by tag once small things are fixed. -Doug