From patchwork Fri Apr 23 03:54:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12219517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7ED2C433ED for ; Fri, 23 Apr 2021 03:54:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EA9E6023F for ; Fri, 23 Apr 2021 03:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbhDWDzU (ORCPT ); Thu, 22 Apr 2021 23:55:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231277AbhDWDzU (ORCPT ); Thu, 22 Apr 2021 23:55:20 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 442E4C061574 for ; Thu, 22 Apr 2021 20:54:43 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id oc5-20020a17090b1c05b029014c095a5149so22474890pjb.2 for ; Thu, 22 Apr 2021 20:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=9y36gi9OG7U6SdUqvogPYMqazMqDYQ87jPlmZy0kjns=; b=D+Ndknek6dc3djnFCrOEZR0FI15q7lH9+uNveWvIOnrdmu23vg3ZrCw05AC/QKpaVp MVN49Kt+MwNwsett3Jmb3r8CKo+c8UQTvfFAnE17EI1x5lXhbRpSdwBi/bbbOe/7SVml 2PwnGBkQnQPJYgT2hbsBw10FQQE5NXyBD8vMLCihtZzNz5HyAk4qCcvwtatXwPlslufQ D2b2rlmizK31mMMLN1y78fgX+o/ITVKMW2DXDkBdwvxoAe2iTJSE16dDGTY1k47BKIS/ HF1sSgD2sktsr3gJkKkYAzHwzf2eerJejeQyM+K7iwR1VJGGCU974I6VOVlxzZRlVVFQ 9gew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=9y36gi9OG7U6SdUqvogPYMqazMqDYQ87jPlmZy0kjns=; b=MC2frFNHu4RkRC7LQIxG1R3qEqMcU3CJ28q3aa0flO4S1hjZNxLBbQzAdwTC0foj9q 3fVtBvm60MB+p9j3nO4DI3fCXADAVePJYbkTq96TqkOFUCV46zQth9qwXkC9pBqB34UK 17bORJZdQKKN7xvePri0UNqAkdMjc3Hg9aqkOi3n9rN8PvyedixLtMGsDYG/smTGc7g8 +kcPld9XJZc2pGaOcOupXRUSJCy5nUpA2gD8YYFoDq14gO+yQG/Pbu0QQhll6mwz0yEB NwWuuJ2ixlFMGmztSgMBEG4qfsECANjHsaf0HAnIXxK2BIfbIVNEJBh2G2VsmKhTziu+ GbWg== X-Gm-Message-State: AOAM531WdjEvd2350ahqlx8fI3IPNpQK8GzL9tdWUqCcTsGk7muIcYaU 0IrMepgsnZREyMQAcn9iZj6nC0512GKtFaUCtistfhkdQYqq6sOmAfLVCwvG6MfDph75TOe17MX aOKdd7AzDACJ42cZzbBm6r89fOYwP04em11TtWdRhOb7A+YCAjFNM3jeMEalnONmSI+GpMisMHY TMj+A= X-Google-Smtp-Source: ABdhPJxF+57OjO0zVuWPnXln5O6puUrmVfmlqMv3TR67j1yTHYh0B8gIF/fKgILFVX4F4ELUOjMXhs9Y04N3 X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:3c22:2043:cc12:f66f]) (user=irogers job=sendgmr) by 2002:a17:90a:b105:: with SMTP id z5mr3401148pjq.187.1619150082567; Thu, 22 Apr 2021 20:54:42 -0700 (PDT) Date: Thu, 22 Apr 2021 20:54:36 -0700 Message-Id: <20210423035438.2221760-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH 1/3] libtracefs utest: Silence string-plus-int warnings 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 Fix warnings of the form: utest/tracefs-utest.c:476:35: error: adding 'int' to a string does not append to the string [-Werror,-Wstring-plus-int] CU_TEST(strstr(kprobes, KPROBE_1 + 2) != NULL); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ Signed-off-by: Ian Rogers Acked-by: Tzvetomir Stoyanov --- utest/tracefs-utest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c index edb3a3d..c5efd5f 100644 --- a/utest/tracefs-utest.c +++ b/utest/tracefs-utest.c @@ -453,21 +453,21 @@ static void test_instance_file(void) CU_TEST(ret == strlen(KPROBE_1)); kprobes = tracefs_instance_file_read(NULL, KPROB_EVTS, &size); CU_TEST(kprobes != NULL); - CU_TEST(strstr(kprobes, KPROBE_1 + 2) != NULL); + CU_TEST(strstr(kprobes, &KPROBE_1[2]) != NULL); free(kprobes); ret = tracefs_instance_file_append(NULL, KPROB_EVTS, KPROBE_2); CU_TEST(ret == strlen(KPROBE_2)); kprobes = tracefs_instance_file_read(NULL, KPROB_EVTS, &size); CU_TEST(kprobes != NULL); - CU_TEST(strstr(kprobes, KPROBE_2 + 2) != NULL); + CU_TEST(strstr(kprobes, &KPROBE_2[2]) != NULL); free(kprobes); ret = tracefs_instance_file_append(NULL, KPROB_EVTS, KPROBE_1_RM); CU_TEST(ret == strlen(KPROBE_1_RM)); kprobes = tracefs_instance_file_read(NULL, KPROB_EVTS, &size); CU_TEST(kprobes != NULL); - CU_TEST(strstr(kprobes, KPROBE_1 + 2) == NULL); + CU_TEST(strstr(kprobes, &KPROBE_1[2]) == NULL); free(kprobes); ret = tracefs_instance_file_clear(NULL, KPROB_EVTS); From patchwork Fri Apr 23 03:54:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12219519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A822AC433B4 for ; Fri, 23 Apr 2021 03:54:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83DF161208 for ; Fri, 23 Apr 2021 03:54:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235302AbhDWDzV (ORCPT ); Thu, 22 Apr 2021 23:55:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231277AbhDWDzV (ORCPT ); Thu, 22 Apr 2021 23:55:21 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72B51C061574 for ; Thu, 22 Apr 2021 20:54:45 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id u3-20020a2509430000b02904e7f1a30cffso22678127ybm.8 for ; Thu, 22 Apr 2021 20:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=56mHbNi+R6K7bh8gB7ZH0RQCkzW3yUyT7UcMyCtPH40=; b=UknrSXEcNRAz83IHKwbnnlltEvO52xid+PKyztVhwuiz+2iWFTOTJrMQAy8XlzI3XK TXHMXppqcrvUWZFmCrsLqlosm/mxtCbWQMIv81rvog0kxZ+Yu7/atIUmLiR9rto6zV1P hkQV/pe/ClvUeyCHuQ4Ujby8TUIp5cjefWVRQDtthfhOl+aiwnYgx7dQ+CTRkLUl4T20 SHb6KDXKi1U0Dyh32yZ2eKS/2+WiuHbjL83kwBMQ1gFlde5mX8CcWHkqCCxpVkdx8YsF JOi9QhL78is2pyEX1ZzxwgASRRznDwDnC18jPxs6bfeOAF32FKhjkm3I5HSlUa8DMee1 7rOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=56mHbNi+R6K7bh8gB7ZH0RQCkzW3yUyT7UcMyCtPH40=; b=O6Gg4lOQmqwctS+8+cngU6IzBl+zwWN10AmewWL+TraphiuG8egZzYn+Sru74reeuZ lfKEdD/ooiG6WV8jnZkTZdRpbSHJIa+3u+WseihRb+w3nQS63Cx4LoMLxYHZRXbJLc/l XxdOzigaBYBeqOIrezG2j6AT7JuVuBV2xeX7fY4r5nVyaS8/MoMkLqtahqLY3Ikhlk5T 1esILm/A5JxrISiLqkVupCanr5tXYoAnN0f6YQlvbw4m/JVhapnicBzSuaGom/zm1qG/ KJfJf3TyZImP3ORryvC/Mryd+ucLSuEWjWtbR0pkYZf6q0HwL+dklmQ8UXhqV97s9t3j Nzbw== X-Gm-Message-State: AOAM530KQ9zfbMHRR+6GN2581F0guo8ZFp8y0I6l0d4bVJtBW9SPBB3H Gnt6y6/P1CY+ohdWANZWFXROmqtPc/o1ml9GjsOFtlMMrqD8z2pamdvESJkbKlaHUwp0Zm30WkX LvKOpkGyKmrg4UXhZI8WR2QY9kOGSaRi9Ge3Mez/0O8bzb6YOWyACibqY7LJ47u6rI+qlmyeVsZ tAITc= X-Google-Smtp-Source: ABdhPJy49jUh0hzUz7QJ52zNR+AQ70kb8C1PEi2uF08CiOq+ri2Q0BfTyHqiNjB3lF9OBSx9tDz3iY2fqwsm X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:3c22:2043:cc12:f66f]) (user=irogers job=sendgmr) by 2002:a25:71d7:: with SMTP id m206mr2791696ybc.282.1619150084568; Thu, 22 Apr 2021 20:54:44 -0700 (PDT) Date: Thu, 22 Apr 2021 20:54:37 -0700 In-Reply-To: <20210423035438.2221760-1-irogers@google.com> Message-Id: <20210423035438.2221760-2-irogers@google.com> Mime-Version: 1.0 References: <20210423035438.2221760-1-irogers@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH 2/3] libtracefs utest: Fix a sometimes uninitialized variable. 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 The warning looks like: utest/tracefs-utest.c:706:7: error: variable 'fd' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (rstat != -1) ^~~~~~~~~~~ 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 c5efd5f..a0d911b 100644 --- a/utest/tracefs-utest.c +++ b/utest/tracefs-utest.c @@ -659,7 +659,7 @@ static bool check_option(struct tracefs_instance *instance, bool supported; struct stat st; char buf[10]; - int fd; + int fd = 0; int r; int rstat; From patchwork Fri Apr 23 03:54:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12219521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8913CC43460 for ; Fri, 23 Apr 2021 03:54:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6AC5D61208 for ; Fri, 23 Apr 2021 03:54:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235684AbhDWDzX (ORCPT ); Thu, 22 Apr 2021 23:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231277AbhDWDzX (ORCPT ); Thu, 22 Apr 2021 23:55:23 -0400 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 7851AC061574 for ; Thu, 22 Apr 2021 20:54:47 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id z8-20020a2566480000b02904e0f6f67f42so22974652ybm.15 for ; Thu, 22 Apr 2021 20:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=MLwUC0ZUWKn51dYIAQ1E36aOLYJJ/6aEivrPEf4bZ0Q=; b=Jnjiq4KXa0XZqikCO+mI47zjGMG02CsEFsbHOWZkmanx7TkRieikAth9g/CO+ooEe9 RRg1+jmhyJEIbMM11f7ZZDpit8ZUFKOIpsH3CThUNKxvqeN879WVKH3Je9GSylNRsbvG jAi/cySEyIvyhExL4P8Y5Bovz/owDLFfKKBwNh0GW7BP33J2CkrtqfhjIvh5fCj5BrOn L9yQJyAccYZ5bQBbOwJ+ty8HrlSmyWoos69mtVOsKDROiRxJ3/EPQZK+eVzFK/d1Jl3Y YlqZO2Zp4sLwe8CMuBuzkAwFR9++yeO1ERFY3uxCShhKhF9XHk5GWb3GlJBlvRW4maZi iGoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=MLwUC0ZUWKn51dYIAQ1E36aOLYJJ/6aEivrPEf4bZ0Q=; b=bVn0tSnit4welr/++iXzqxdkw08lvlcwL4Q8FNHXqZUHyy2SFVxanVR4xDBBh1Nkdk gef398T+AliRAHpYEHAuSaRVGWNzQM83Zz/TnK8ZAw+TpPRZvrcHMupSLnbhjX9rwRsQ PJntzwGILeSvcYq/fwVnDNhc/VpwrYt1XCY8XHh6ziFUONiXpl+PhqCvIPHPU1A9rIhV T//t7uzWIh+bhkveVxTjEHm1ex1P7ZqZG94VSiMqTPP4JieNMPmiL0W8Rz8b3TsMJUYa DNSSLryadOJg53lyGRJ9sU6XHP0yKgHT093XR4ueRMnG0J5GhtoEjYY1/8sJ50RUZBvq Nuug== X-Gm-Message-State: AOAM530ICSeCPf0qBXxWiPr1XPJJWMqs5zwCTXSvcUQQAj/39CnIqB8a OAm6f2mHqafRH+t9n5ishkKWOsFFT9PBuewfGLcXTyJYFsnIltiu2SCjhu2Dln2MAy1bH+5wLql Ag5aFxYKyf3tzD150k/oNwlCNVh20H+575ZyEtUVk6MA2kzQLoqc/loI7Fp7qgY/FwcKrnAqKh4 Knh7Y= X-Google-Smtp-Source: ABdhPJzC0FXPH++f69MXTcIOnBCEPvDDVHkp+JYvvblK9EDFi6pK+yZ0lOt/1+i0D06LHTdv3sg6LTfEd3wm X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:3c22:2043:cc12:f66f]) (user=irogers job=sendgmr) by 2002:a25:c0d5:: with SMTP id c204mr2738074ybf.57.1619150086651; Thu, 22 Apr 2021 20:54:46 -0700 (PDT) Date: Thu, 22 Apr 2021 20:54:38 -0700 In-Reply-To: <20210423035438.2221760-1-irogers@google.com> Message-Id: <20210423035438.2221760-3-irogers@google.com> Mime-Version: 1.0 References: <20210423035438.2221760-1-irogers@google.com> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog Subject: [PATCH 3/3] libtracefs utest: Make a null string fatal if it is passed to strstr 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 strstr will segv for a null string. If a string is passed to strstr and is null there is no point segving, it is better to fail the earlier test with a fatal and continue the rest of the suite. This allows the suite to complete with an error rather than die. Signed-off-by: Ian Rogers --- utest/tracefs-utest.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c index a0d911b..e846dc4 100644 --- a/utest/tracefs-utest.c +++ b/utest/tracefs-utest.c @@ -452,21 +452,21 @@ static void test_instance_file(void) ret = tracefs_instance_file_write(NULL, KPROB_EVTS, KPROBE_1); CU_TEST(ret == strlen(KPROBE_1)); kprobes = tracefs_instance_file_read(NULL, KPROB_EVTS, &size); - CU_TEST(kprobes != NULL); + CU_TEST_FATAL(kprobes != NULL); CU_TEST(strstr(kprobes, &KPROBE_1[2]) != NULL); free(kprobes); ret = tracefs_instance_file_append(NULL, KPROB_EVTS, KPROBE_2); CU_TEST(ret == strlen(KPROBE_2)); kprobes = tracefs_instance_file_read(NULL, KPROB_EVTS, &size); - CU_TEST(kprobes != NULL); + CU_TEST_FATAL(kprobes != NULL); CU_TEST(strstr(kprobes, &KPROBE_2[2]) != NULL); free(kprobes); ret = tracefs_instance_file_append(NULL, KPROB_EVTS, KPROBE_1_RM); CU_TEST(ret == strlen(KPROBE_1_RM)); kprobes = tracefs_instance_file_read(NULL, KPROB_EVTS, &size); - CU_TEST(kprobes != NULL); + CU_TEST_FATAL(kprobes != NULL); CU_TEST(strstr(kprobes, &KPROBE_1[2]) == NULL); free(kprobes); @@ -1026,7 +1026,7 @@ static void current_clock_check(struct tracefs_instance *instance, const char *c char *str; clocks = tracefs_instance_file_read(instance, TRACE_CLOCK, &size); - CU_TEST(clocks != NULL); + CU_TEST_FATAL(clocks != NULL); CU_TEST(size > strlen(clock)); str = strstr(clocks, clock); CU_TEST(str != NULL); @@ -1041,7 +1041,7 @@ static void test_instance_get_clock(struct tracefs_instance *instance) const char *clock; clock = tracefs_get_clock(instance); - CU_TEST(clock != NULL); + CU_TEST_FATAL(clock != NULL); current_clock_check(instance, clock); free((char *)clock); }