From patchwork Fri Mar 2 10:43:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev\" via" X-Patchwork-Id: 10254215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9BA1E602B5 for ; Fri, 2 Mar 2018 10:44:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86D752894F for ; Fri, 2 Mar 2018 10:44:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7880228956; Fri, 2 Mar 2018 10:44:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8F31D2894F for ; Fri, 2 Mar 2018 10:44:30 +0000 (UTC) Received: from localhost ([::1]:33946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eriAv-0001V9-IO for patchwork-qemu-devel@patchwork.kernel.org; Fri, 02 Mar 2018 05:44:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eriAJ-00014c-N5 for qemu-devel@nongnu.org; Fri, 02 Mar 2018 05:43:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eriAG-000813-JJ for qemu-devel@nongnu.org; Fri, 02 Mar 2018 05:43:51 -0500 Received: from smtp2.mail.ru ([94.100.179.91]:48570) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eriAG-00080W-6w for qemu-devel@nongnu.org; Fri, 02 Mar 2018 05:43:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Message-Id:Date:Subject:Cc:To:From; bh=5GrJLiXehc1hRp+MgNbb+3U8wfiyTI2+aDxH8HS6LZc=; b=r+es6Z7/qDj8Z17l7CL+Ig5c/fhzNmFUQS9Ur07Ed/+UsBCc5wWzo3xSTbVG7uf48zGDTCx/zKl9HJ4tcFjefQsqLkE08kTCJqh6n/zLM7RlqhV7wMfzF/8aqNQmdY6BAjANaJuBS9zS4aMInmYihtodWsx0LdJikq1d+AV2NRE=; Received: by smtp2.mail.ru with esmtpa (envelope-from ) id 1eriAD-0002iO-NC; Fri, 02 Mar 2018 13:43:46 +0300 To: qemu-devel@nongnu.org, Stefan Hajnoczi Date: Fri, 2 Mar 2018 13:43:19 +0300 Message-Id: <1519987399-19160-1-git-send-email-jusual@mail.ru> X-Mailer: git-send-email 2.1.4 Authentication-Results: smtp2.mail.ru; auth=pass smtp.auth=jusual@mail.ru smtp.mailfrom=jusual@mail.ru X-7FA49CB5: 0D63561A33F958A5AF894A7001C322954BFDE001693B57BE8317D92693558284725E5C173C3A84C3DD19ECFA348986C5D38F82E63B2096D55705F49E3A860CEDC4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0FF045C6A0F83C8214574AF45C6390F7469DAA53EE0834AAEE X-Mailru-Sender: E03EFFB74E926B2DFC3B87178F5C03BE20EAF23A97DC3909F26BB195EADBFF8AAAC282D28BAD68527C4160E8B47E48163DDE9B364B0DF2898CB68AF7A628805D594FB4C9F0DBF412AE208404248635DF X-Mras: OK X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 94.100.179.91 Subject: [Qemu-devel] [PATCH v2] checkpatch: add a warning for basename/dirname X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Julia Suvorova via Qemu-devel From: "Denis V. Lunev\" via" Reply-To: Julia Suvorova Cc: Jim Mussared , Cornelia Huck , Joel Stanley , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Julia Suvorova Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP g_path_get_* do the same as g_strdup(basename/dirname(...)) but without modifying the argument. Signed-off-by: Julia Suvorova --- scripts/checkpatch.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1b4b812..a88af61 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2584,6 +2584,11 @@ sub process { ERROR("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); } +# recommend g_path_get_* over g_strdup(basename/dirname(...)) + if ($line =~ /\bg_strdup\s*\(\s*(basename|dirname)\s*\(/) { + WARN("consider using g_path_get_$1() in preference to g_strdup($1())\n" . $herecurr); + } + # recommend qemu_strto* over strto* for numeric conversions if ($line =~ /\b(strto[^kd].*?)\s*\(/) { ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr);