From patchwork Thu Dec 15 18:31:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13074457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CE05C4167B for ; Thu, 15 Dec 2022 18:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbiLOSeD (ORCPT ); Thu, 15 Dec 2022 13:34:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230311AbiLOSdh (ORCPT ); Thu, 15 Dec 2022 13:33:37 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F29AF242 for ; Thu, 15 Dec 2022 10:31:59 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id x188-20020a2531c5000000b00716de19d76bso4774024ybx.19 for ; Thu, 15 Dec 2022 10:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=cQiNqKdPjqw4QnOS79pxkaJEwk3jEFOQF0llvUiiH9Y=; b=renTso6WCBWxtuszmFZjnngIPAOzTdnVDmy8FwnqudUHboBAfGWw+ZYgRVqul4cTJ+ 9vXIPh8dfha7sQdQPAiJRG0Z/B82L0TYgNQBho7MZWWh4EQSVzzavcSUIhjVoiXWSwv2 zH2jIGpJ4mHsGTwBvS6nWMEhNLT4AlpS2ALruUJwKEorQKywvCyBySu5iSVJo3Ep6uQt 8Aq48itutjckr5TBtNjDhgcXT2BSoVAJI8Ea6FpfhYejon8VbTzS6zlh2fKnMDCFqk3K JOS6KmokNCxw6xI5mXypuW/zjZZiiLygTuXThXRg3o0NIVAbY2IwnFipzirGLCjj+rLd E6FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cQiNqKdPjqw4QnOS79pxkaJEwk3jEFOQF0llvUiiH9Y=; b=Ur80+flm7deN3YF0kZ697pFix/lFXvlJm26GzNWnUs7/6M6tRi/bpVRoLBSpz2JbwT /7Q9WOvROAqJ2AeVPmquhwC+AHbHNRb6GAGUjdcXJ2mYSm3WD5Owq0+akEoXSJcLE05N tKbJ1X1KEEe503+D18AXdzkSxsCM/PveUhdHMxpgGG9peTqAQ1UC06nI7jWsEOqw8Pfq GaQFpkg5NGZlaUIdNAdPqVHdn5jWZagxvJNvTZ7S+inIR+tbArFR1B1wdINWutWWsjWf fmcs9Fd35NtIbTqe8mqaNf7+QZxOIPcGTL98zoG4bJAmwmp/69i5r9HZaysIzVqksRf2 fwBA== X-Gm-Message-State: AFqh2kqSIyAmuJcaG8pFa6MGJ8EBM5nrDkaR6c8poEeuz9plH8H2MMha F7ecssuY1ruq4l2SzegM4SeeOA5ypjehznQiXSrgXWPKcfcK5bFPMi2lfY/33ijuvuud9bstYYT c2M9cnM6riPVzLZuCwZwspNiwYoy+X/JFZyAO3OaA8+cu+TF7aEvCe3q8Tfv/NiN/nWwgHZNHZG /sDCU= X-Google-Smtp-Source: AMrXdXtWeIFDBVzvRDQ8zhyYdo7h2YF/kbn3w5QdpFyqX4VYpTO01lAzPbLX9S2aDyqm+hfqaMdNFLJ4GJQF X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:de6d:aa93:7423:e679]) (user=irogers job=sendgmr) by 2002:a25:6f46:0:b0:739:a1c7:f11a with SMTP id k67-20020a256f46000000b00739a1c7f11amr102751ybc.461.1671129119188; Thu, 15 Dec 2022 10:31:59 -0800 (PST) Date: Thu, 15 Dec 2022 10:31:50 -0800 Message-Id: <20221215183151.2685460-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Subject: [PATCH v1 1/2] libtracefs: Move initialization below a null test. From: Ian Rogers To: linux-trace-devel@vger.kernel.org, Tzvetomir Stoyanov , Steven Rostedt Cc: Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Computing the address from a NULL pointer results in undefined behavior which things like undefined behavior sanitizer promote into real failures. Signed-off-by: Ian Rogers --- src/tracefs-dynevents.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tracefs-dynevents.c b/src/tracefs-dynevents.c index 48bb26a..02e8023 100644 --- a/src/tracefs-dynevents.c +++ b/src/tracefs-dynevents.c @@ -709,13 +709,18 @@ dynevent_info(struct tracefs_dynevent *dynevent, char **system, char **event, char **prefix, char **addr, char **format) { char **lv[] = { system, event, prefix, addr, format }; - char **rv[] = { &dynevent->system, &dynevent->event, &dynevent->prefix, - &dynevent->address, &dynevent->format }; + char **rv[] = { NULL, NULL, NULL, NULL, NULL }; int i; if (!dynevent) return TRACEFS_DYNEVENT_UNKNOWN; + rv[0] = &dynevent->system; + rv[1] = &dynevent->event; + rv[2] = &dynevent->prefix; + rv[3] = &dynevent->address; + rv[4] = &dynevent->format; + for (i = 0; i < ARRAY_SIZE(lv); i++) { if (lv[i]) { if (*rv[i]) { From patchwork Thu Dec 15 18:31:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13074456 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CACDC4332F for ; Thu, 15 Dec 2022 18:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbiLOSeC (ORCPT ); Thu, 15 Dec 2022 13:34:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230324AbiLOSdh (ORCPT ); Thu, 15 Dec 2022 13:33:37 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC00B297 for ; Thu, 15 Dec 2022 10:32:01 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id o31-20020a17090a0a2200b00219a2904952so11718pjo.0 for ; Thu, 15 Dec 2022 10:32:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Dc7J5VfqbkePBXIcgmZn1rBMkBEEP9PdPFeu+rapwn8=; b=Zgkg6g15fuCmGOaGbUwX+DVt0MM2gXcYqfhH6lKPCd9o1XnPnzMZ+aAAFOxLgrYxJo 9UxcNT8DLTrroANFs1QxseqjFECbMl0LtnLRAeqqMc8htFOQO4gJ1cuhLeELcS0OEn9K WjizM93SnsvcK05hgGHmp0kRRsgiYW1suDseT5jVJNLlynnOcmMA+SE4uXi5LWw3o4A9 wKZ8HG2gbt+cxna+wMu8QyQczJyn5eXytzzDuQS7bpmXcPI1eKG7mHf0bp/DLwu3xuuf 6uWD7PCg6gWt8+onXqyqp/nkbqvuyEoPbJL+FIsVfuE+nDVjqGxGft/rUU43C46wHeaG wYmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Dc7J5VfqbkePBXIcgmZn1rBMkBEEP9PdPFeu+rapwn8=; b=BXYBtK1vWX/CWum7RQ95pzy5+hSzWgCQKSXJJ/ZaHaBgasbhUnmho68XeaxKbooagU a93GLaLxWR8cK47h2AWUplGjHs6/dTUbgouh2mwEUFj+QfIvi9zbMKQnx1Yfr4SWyymT AZKgQF23nhOcHM+sfEgrJjvz3MLC8wC9xr1xEkmJk+cKicz2m/b1LRmp5XSMVFafEVOm JIjHxIeCSaDEn5pNPDeZ9dUH6YPTzgLCl3S+KXwQBJ4QThH941ebkAq5jwWlDtJ5sJ96 7CAfq4UxckCq5j0ldserO8NL7E2agCP17P0YX3r2l2Rk+JeKoPry2n/qb/JxatMgrrPF eSbQ== X-Gm-Message-State: ANoB5pkv371oYM3Pa7Cmtf0a5IlMGDfJx/8P8AespTcF4SYfTmTDeNIO AgK3LlAWc5NPO4Gyg4xXZy8dfZzw0ezEFHeTftVCDfrWlltgu2AuRsANjuiUF4Xk3TSXnZBfICk T/BitFEYYAk9GI9y/8x57voDzup89VT6m/pbi/AehAV8e/yG1CQdKDm40ySVKrE0LSSupcfCNXi TNMn0= X-Google-Smtp-Source: AA0mqf6Ke0aSrnZFVXgsgRCsUq8lS6wwvWXWBdddFjPYv0PtbWxFUg39zibns8tJtdRJcaoKNwDLQhOVfmPp X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:de6d:aa93:7423:e679]) (user=irogers job=sendgmr) by 2002:a05:6a00:10c9:b0:57a:9cfb:3490 with SMTP id d9-20020a056a0010c900b0057a9cfb3490mr586061pfu.86.1671129121304; Thu, 15 Dec 2022 10:32:01 -0800 (PST) Date: Thu, 15 Dec 2022 10:31:51 -0800 In-Reply-To: <20221215183151.2685460-1-irogers@google.com> Message-Id: <20221215183151.2685460-2-irogers@google.com> Mime-Version: 1.0 References: <20221215183151.2685460-1-irogers@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Subject: [PATCH v1 2/2] libtracefs: Fix compiler -Wmemsize-comparison warning From: Ian Rogers To: linux-trace-devel@vger.kernel.org, Tzvetomir Stoyanov , Steven Rostedt Cc: Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Fixes the following clang warning: utest/tracefs-utest.c:828:75: error: size argument in 'strncmp' call is a comparison [-Werror,-Wmemsize-comparison] (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0))) ~~~~~~~~~~~~~~~~~~~^~~~ utest/tracefs-utest.c:828:22: note: did you mean to compare the result of 'strncmp' instead? (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0))) ^ ~ ) utest/tracefs-utest.c:828:56: note: explicitly cast the argument to size_t to silence this warning (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0))) ^ (size_t)( ) Signed-off-by: Ian Rogers --- utest/tracefs-utest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c index 629cf2b..e0e3c07 100644 --- a/utest/tracefs-utest.c +++ b/utest/tracefs-utest.c @@ -825,7 +825,7 @@ static void test_mounting(void) mount("debugfs", save_debug, "debugfs", 0, NULL); if (save_tracing && - (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug) != 0))) + (!save_debug || strncmp(save_debug, save_tracing, strlen(save_debug)) != 0)) mount("tracefs", save_tracing, "tracefs", 0, NULL); free(save_debug);