Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2618687lqt; Mon, 22 Apr 2024 17:00:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXql7N4qOEW8W0JKh0Xko5iXgYOnhOxjLG07h9+lS8RP2NI8DSOD/R4NT4SgIvUWETc2+paceEJsRFwlmpk74L+1FmVCyi69uHPVT+FoQ== X-Google-Smtp-Source: AGHT+IGToAspN5DCinEgsNPw/CUiTn03L4DKydNMew9bCM5M+r2li/7h7xKI5WJx9LWiUnjLd/6r X-Received: by 2002:a05:6871:208b:b0:234:d838:eed9 with SMTP id ry11-20020a056871208b00b00234d838eed9mr14317884oab.9.1713830450259; Mon, 22 Apr 2024 17:00:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713830450; cv=pass; d=google.com; s=arc-20160816; b=u9hytHuriAf/1ZV+RmyLFaQg4DS+txOlEIyrxmJc+v7d8pO/hFmiu+rsXQ97cWzGTj 6Tho60Hd76iaibUvubPbHlsc0TNsCj9G3wBMVJYhyvcMX+zJRRprUs6UcZTtpzuoM+be ZE33UbEtQj3z/wTMakrCiuSrfSU9kFzyPMpRlBpS6aY3HpNLjT8/VPTbErpiD7MQjohh OTZ93+9flDGiyITnvEBhduVLtERKvyUOZb2iBX7UVCJj1uM1VozwITdObR7ATY2gb7o4 LP35+Btqt0O7U0Wl5Zo2g+dIyRu6Lh9UWZAq8Pl2QwxZ3cl8sAVgJMpPIP0n9pE7HEHi wqwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=3DOqaxMdms/qXRzuhL549SToyGg4i6A1dwMfsfdbbL8=; fh=3BfPBUEyCJjMDovaH/tJxOCHyyLSt1mbNaLowa9gFYI=; b=R/agHkjfUWHHgFPoj1GxoTo23Y2kCcK6apycoU/poUlBzFAhy2fGhXYjqE7Byz7vDn mrYAYhlxLZiOAcqbOCiXfENCv7Sc5Z7tmnMomlsfQQTsAOs2MOWfGGH4558OrKjZJIPJ bCZ7X/iMud/IfbcFALqRN8jjmSh2lOpQhAwma33xVWKnup3pSRTJ5gZ1Xzkp0MIqBi1c qmCwp+voO1PZFnQE63Q8qNCEx3dHQk0fSdwcFRCp+mzZ7f3ji6QNMOpJgsC3nBi3fwLP Lmp+9h6PEU2eAxxMy9J7bIZeODmG1SJcO592II1C5SQ20baVZ3fwC/HOOnbN4vW4wzwP hDpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LYMqN4nt; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-154211-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154211-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l65-20020a633e44000000b005f808ee8efasi5241635pga.809.2024.04.22.17.00.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 17:00:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154211-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LYMqN4nt; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-154211-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154211-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5474FB24B82 for ; Mon, 22 Apr 2024 23:52:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C76C45BF1; Mon, 22 Apr 2024 23:52:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="LYMqN4nt" Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F11AE45BEF for ; Mon, 22 Apr 2024 23:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713829946; cv=none; b=odViuGHUB1g9ExpE53uys5rYOF3e42VQO+rgEG+ZyURx7E95M53+BE+HzjjFqPkH9MaIFSApBdoD+fzLbAMOUBN95SDmt5Bs7mje5ySQy1H0+Btw1GYCX8H44EVAtY2woBHHTo4wqUYYSKKrCrjYT5+e61rWNp+Kd9iA1z9meTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713829946; c=relaxed/simple; bh=EHpp7S73gOdRUjxiqhvAAq6aSAY1pPeHrx6OMKnKkiY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=fj2lNyesKCXQM7LpxIpYeFqBMwhNYx0o2/cHLhJFep3q38kczc4hS9yCktYHZuEarJonKAiJx3xYWmEYee13WGdcM2exn+i/3tzLQw1M8Fh8OBseSZm1ZDV0YdJfAgX7VVgjpFUEP3z8AiE/iHC2hffKPE0vuUy38jh0B16P4eg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=LYMqN4nt; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-61587aa9f4cso55773967b3.3 for ; Mon, 22 Apr 2024 16:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713829942; x=1714434742; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=3DOqaxMdms/qXRzuhL549SToyGg4i6A1dwMfsfdbbL8=; b=LYMqN4nt3DdEqAJP0OrcH1KFiHaOJY8rWY2LLSd+Yd7H7KZWyJ+aY3IrVgTmoAGrV2 3uaRFXm/b07uTINi5x1NzPDQN1swjKPL/CVCUl+AceB4x/8vKFgdLNmvQFoTUp3hE9Pt gndfyBftqxqUf/YvIImc5NLf9VIJGAdGleuCQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713829942; x=1714434742; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3DOqaxMdms/qXRzuhL549SToyGg4i6A1dwMfsfdbbL8=; b=GktTyriyTs5tlfAxz+5XWA2biVwjtGKhCJt8s8llL5VA5cqlgBdmlh4TKtapNxSm8o w+U16cG3P9lMfV0+FZCphBgiVmrzz2ek2H012wZq/N1qKbIwSIJfriCJdmeLv9vFU/cl sWAYbIVEGLQG4py/hl0mZDZg4Z5wC48GTKhHC5udHX29StPyu3i+80dkHPSSg/3k2LgR 0xDnSEBt3gb8t3+JL0sq+UW5xcOyJGZNRR2DDJlAUpDe+P9FbEmCq3fLfw5Oi5rHFBRQ U7otQEXKF6R/3Tm7PT7EYJsva9EcDBHxwVflmdh/w0hg6w6y9z4ENFxRh7/oTO95hE3/ fF+A== X-Forwarded-Encrypted: i=1; AJvYcCVnlrQGuxfmBfjOV2Yy3VVYTBWZt34z+8Y2cmhhu97xms7aP8SfZhCz4dECrXrf0CcfRa83fNufcvasazGrmJTvCTmJX+FQ3v3ZR6rs X-Gm-Message-State: AOJu0YyyBY/kOKdxD53ocKe5OvN8FDDCzJ2Uh0KP6I5R054PmqZC4jll eAWSrFDVnDztw6zKncX5O3t2tTKQzfgUOrWif9pXrUvTrBK/y0u7NbtUg8yYotXQ4N4UYDystm5 wbtDY X-Received: by 2002:a05:690c:7209:b0:61b:33b6:41dd with SMTP id jl9-20020a05690c720900b0061b33b641ddmr12761514ywb.37.1713829942149; Mon, 22 Apr 2024 16:52:22 -0700 (PDT) Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com. [209.85.160.177]) by smtp.gmail.com with ESMTPSA id t13-20020a05620a004d00b0078efd956945sm4758489qkt.126.2024.04.22.16.52.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Apr 2024 16:52:21 -0700 (PDT) Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-439b1c72676so100991cf.1 for ; Mon, 22 Apr 2024 16:52:20 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCW1A3Kc4z3sC2NPBgUGYJ52r8bmf30G7xhUqPdGi/OJtZJ0jSFUmlmjm00FYr6rhb8mfWASVPz7U2NxbT9cp0VPdmopNItJKG1n/NcW X-Received: by 2002:ac8:6682:0:b0:439:891f:bbd2 with SMTP id d2-20020ac86682000000b00439891fbbd2mr122734qtp.28.1713829940394; Mon, 22 Apr 2024 16:52:20 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240422-kgdb_read_refactor-v2-0-ed51f7d145fe@linaro.org> <20240422-kgdb_read_refactor-v2-2-ed51f7d145fe@linaro.org> In-Reply-To: <20240422-kgdb_read_refactor-v2-2-ed51f7d145fe@linaro.org> From: Doug Anderson Date: Mon, 22 Apr 2024 16:52:04 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/7] kdb: Use format-strings rather than '\0' injection in kdb_read() To: Daniel Thompson Cc: Jason Wessel , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Mon, Apr 22, 2024 at 9:37=E2=80=AFAM Daniel Thompson wrote: > > Currently when kdb_read() needs to reposition the cursor it uses copy and > paste code that works by injecting an '\0' at the cursor position before > delivering a carriage-return and reprinting the line (which stops at the > '\0'). > > Tidy up the code by hoisting the copy and paste code into an appropriatel= y > named function. Additionally let's replace the '\0' injection with a > proper field width parameter so that the string will be abridged during > formatting instead. > > Cc: stable@vger.kernel.org # Not a bug fix but it is needed for later bug= fixes > Signed-off-by: Daniel Thompson > --- > kernel/debug/kdb/kdb_io.c | 34 ++++++++++++++-------------------- > 1 file changed, 14 insertions(+), 20 deletions(-) Looks like a nice fix, but I think this'll create a compile warning on some compilers. The variable "tmp" is no longer used, I think. Once the "tmp" variable is deleted, feel free to add my Reviewed-by. NOTE: patch #7 in your series re-adds a user of "tmp", but since this one is "Cc: stable" you will need to delete it here and then re-add it in patch #7. > diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c > index 06dfbccb10336..a42607e4d1aba 100644 > --- a/kernel/debug/kdb/kdb_io.c > +++ b/kernel/debug/kdb/kdb_io.c > @@ -184,6 +184,13 @@ char kdb_getchar(void) > unreachable(); > } > > +static void kdb_position_cursor(char *prompt, char *buffer, char *cp) > +{ > + kdb_printf("\r%s", kdb_prompt_str); > + if (cp > buffer) > + kdb_printf("%.*s", (int)(cp - buffer), buffer); nit: personally, I'd take the "if" statement out. I'm nearly certain that kdb_printf() can handle zero-length for the width argument and "buffer" can never be _after_ cp (so you can't get negative). -Doug