Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp213386ybm; Mon, 20 May 2019 14:51:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJ+q7F97HzIXb7LByU4FkU+iB1gIWodWFFIXXdTuAkOXE8K18JKmc98kuVr1mWhCP9hj0y X-Received: by 2002:a17:902:d892:: with SMTP id b18mr34357855plz.216.1558389083878; Mon, 20 May 2019 14:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558389083; cv=none; d=google.com; s=arc-20160816; b=BRALlpMo8EfxhWbvsF2IuvodK/SkVqdwi8c24OEWgNqIvs/UXaRKq80caNk1e6tkrO ZAFrtcRXQdyn9JBdtrk4MvcF1zwucvFVtCjPMp/uz7F93YTlUrkw4YoT6DK9aJca/sN4 Qdsm/pM3Mxkcci8mPT9JTCUZneWq3+jUy29M2gRBgRFT8VzbUow97H96JFmn69SsNGwg zrAGRzY06vnkdZvHvuynHQklzg/lELmfAL1MN6I7fhzaDxzzhK9AJs2co5W8jrECErVb Fo+xYXSQEbKFC1dgqLWz46vsfmPm1Be9AAB83a/1AV4eQ53mSqN/kgSmdfsorCGu4KQs sBEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=5T1hy/hqtkGt7VlP8D6U9UrQi3KpGadAce8jNWj5ow4=; b=eWxdFPPRj/OFtpFznPB6X3iMpFgABNIZX7pqqzLMrYQNVP87zEb2b+6QU7dPlXgIRr nLIzxEASdqISwf5p8fQ3gP4h8iHqwVexIdYBhR4kgZR97IpYCqM7nbhX6DRpuO0d8HsV exI5cE+ejrPDPyOuq1ecz4sep+xrEnwawkpaIaV3CmNTLwNKaOJxNZqjx8Rup5u09uwH cZeKmpLOl5lsfcZpwXXzHW1wqNwQNzwj57z9FgIA7zvPq/4tVqZzeurz12MyCrWJ5y9X ZxqiCmP5wDjCPftPuQpsyIPhRTpm0EY8mwhcVcd3c/KlXqE1Ovb7tBCOPqAbZuwn08bc XWIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q20si21980031pfn.139.2019.05.20.14.51.08; Mon, 20 May 2019 14:51:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726730AbfETVtl (ORCPT + 99 others); Mon, 20 May 2019 17:49:41 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46315 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbfETVtl (ORCPT ); Mon, 20 May 2019 17:49:41 -0400 Received: by mail-wr1-f68.google.com with SMTP id r7so16174142wrr.13 for ; Mon, 20 May 2019 14:49:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5T1hy/hqtkGt7VlP8D6U9UrQi3KpGadAce8jNWj5ow4=; b=r++twI/ShsNsxuBkgV04OztRWjO22hNV40Fcv4TGA71xTedEGdK/LYWWJ/Wkpge5gm wdcAQY/odvY0WAgtJ6v8F1Z494RfUH9XszZh1hFb9y4zHVU+3gX2+vLQCyvsJD4A+a8h hNSYY5jtNtiV4/tbT6I/PxprJ+7xT9Vprz1paJcYQchhTJEH3gCKIbAD2oAgStQZGJlX BMbJMXVY1hhUKMeR8ihCYmwHYVs8cvpnbJ5GWBaXNdBdlOYFsfnXe/hgUsZPpNv0IRqi b1Ar16X0YZZhBhl4Ej4KDxkp3tJ9YE1F41MXheU5jreWg/jQavZc33+uirQPeKGaVlId G0nw== X-Gm-Message-State: APjAAAVvYYqhA0OXz/kRTziTQE0HO40ju0zJzSeY997RAsl/2otH2CmC 18k9bCrSmk952zVXcuUYffBnbA== X-Received: by 2002:a5d:4a44:: with SMTP id v4mr2492195wrs.84.1558388979591; Mon, 20 May 2019 14:49:39 -0700 (PDT) Received: from raver.teknoraver.net (net-47-53-225-211.cust.vodafonedsl.it. [47.53.225.211]) by smtp.gmail.com with ESMTPSA id 197sm1466394wma.36.2019.05.20.14.49.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 May 2019 14:49:38 -0700 (PDT) From: Matteo Croce To: xdp-newbies@vger.kernel.org, bpf@vger.kernel.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann Subject: [PATCH bpf] samples/bpf: suppress compiler warning Date: Mon, 20 May 2019 23:49:38 +0200 Message-Id: <20190520214938.16889-1-mcroce@redhat.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GCC 9 fails to calculate the size of local constant strings and produces a false positive: samples/bpf/task_fd_query_user.c: In function ‘test_debug_fs_uprobe’: samples/bpf/task_fd_query_user.c:242:67: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 215 [-Wformat-truncation=] 242 | snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/events/%ss/%s/id", | ^~ 243 | event_type, event_alias); | ~~~~~~~~~~~ samples/bpf/task_fd_query_user.c:242:2: note: ‘snprintf’ output between 45 and 300 bytes into a destination of size 256 242 | snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/events/%ss/%s/id", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 243 | event_type, event_alias); | ~~~~~~~~~~~~~~~~~~~~~~~~ Workaround this by lowering the buffer size to a reasonable value. Related GCC Bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83431 Signed-off-by: Matteo Croce --- samples/bpf/task_fd_query_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/bpf/task_fd_query_user.c b/samples/bpf/task_fd_query_user.c index aff2b4ae914e..e39938058223 100644 --- a/samples/bpf/task_fd_query_user.c +++ b/samples/bpf/task_fd_query_user.c @@ -216,7 +216,7 @@ static int test_debug_fs_uprobe(char *binary_path, long offset, bool is_return) { const char *event_type = "uprobe"; struct perf_event_attr attr = {}; - char buf[256], event_alias[256]; + char buf[256], event_alias[sizeof("test_1234567890")]; __u64 probe_offset, probe_addr; __u32 len, prog_id, fd_type; int err, res, kfd, efd; -- 2.21.0