From patchwork Wed Oct 23 06:29:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rolf Eike Beer X-Patchwork-Id: 13846542 Received: from mx1.emlix.com (mx1.emlix.com [178.63.209.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38AF013BC11; Wed, 23 Oct 2024 06:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.63.209.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729665525; cv=none; b=I3MV+JZcMLObcL4mwgavcx0IQFOKFs8kgHCTyso8Ec/DJvnBMMwA/F+uezUKD1N6mNMrEyvGQmoWqOuTOObVpaxgfVvdCMV9MK5Oo0b/rZMD7lGX/1dLpkbc6GNzyBpq5+ADQDCpybCnC2+9o3r50CKLBT06VmZOb1QIuEdoZ2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729665525; c=relaxed/simple; bh=FkbXTX6/laHtcxuSP/YuZ0C5lTynxiJsq6LDdjhZNnQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c0vlWydoFa+MWuMqPRsPfMtp4KIASEYXYjmKnZtIviz/GiVISRssPG8zVURk2cJjr8+WPk4KiN6JDzmQXVE1ksLvU20MlQORASVXDFYonAPYfXv4f+AIdwfeP5QbHz25UTcOPhViJ5VfRkQGzdYV0IThBNiBL+N7NhSTZwg0poU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=emlix.com; spf=pass smtp.mailfrom=emlix.com; arc=none smtp.client-ip=178.63.209.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=emlix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=emlix.com Received: from mailer.emlix.com (p5098be52.dip0.t-ipconnect.de [80.152.190.82]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id 2BDA25F8A7; Wed, 23 Oct 2024 08:29:32 +0200 (CEST) From: Rolf Eike Beer To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string Date: Wed, 23 Oct 2024 08:29:31 +0200 Message-ID: <4931941.GXAFRqVoOG@devpool47.emlix.com> Organization: emlix GmbH In-Reply-To: <4960180.31r3eYUQgx@devpool47.emlix.com> References: <4960180.31r3eYUQgx@devpool47.emlix.com> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Using a naked char[] here isn't necessary as QByteArray has a nice API for all of this. Calling constData() will also always return a 0-terminated string so no further handling is required. And then the whole manual memory handling can go away as QByteArray will care for this when it goes out of scope. Signed-off-by: Rolf Eike Beer --- scripts/kconfig/qconf.cc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index e260cab1c2af..742ca6ed289b 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1165,25 +1165,17 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char void ConfigInfoView::clicked(const QUrl &url) { QByteArray str = url.toEncoded(); - const std::size_t count = str.size(); - char *data = new char[count + 2]; // '$' + '\0' struct symbol **result; struct menu *m = NULL; - if (count < 1) { - delete[] data; + if (str.isEmpty()) return; - } - - memcpy(data, str.constData(), count); - data[count] = '\0'; /* Seek for exact match */ - data[0] = '^'; - strcat(data, "$"); - result = sym_re_search(data); + str[0] = '^'; + str.append('$'); + result = sym_re_search(str.constData()); if (!result) { - delete[] data; return; } @@ -1206,7 +1198,6 @@ void ConfigInfoView::clicked(const QUrl &url) } free(result); - delete[] data; } void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)