[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] tests/cpu-policy: fix format-overflow warning by null terminating strings


  • To: "christopher.w.clark@xxxxxxxxx" <christopher.w.clark@xxxxxxxxx>
  • From: Jan Beulich <JBeulich@xxxxxxxx>
  • Date: Tue, 30 Jul 2019 15:51:24 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=suse.com;dmarc=pass action=none header.from=suse.com;dkim=pass header.d=suse.com;arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kk0zZdBmwboBjio0W2JTAMerLeeSscqltdCyab2JbTk=; b=TAWSZ2D2okP6K3uWzs6FhkNeRURa8B572kQBb/AF8Cql71YmyZhEDQqkSPO7HkCVxpcCE5IR2qvJJk8dC2dty2zdEiTJPiROIHmiwc7FIPxnzIl7B6gGFQlcbd2Tb0EJ8uc14rQOWC2cPJqfunDk+Bc+XGbNZr9qEBIvF8cmRgyQObyoEWXHrCjslzA2YqlOJv37ycqTwte18i6MTWzUCuMxymHaBLkMKpLWJLElX71epRgwJGacyoU24V+DWEPZtoZ2jHAHKaWGMto7q6hKN7xuV2ueVS2RdN+lUBXaJiR4FzyibhdvQd/OwyJL0+yehHsYnO4vf1z9LHoRQCAAYw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yx0gVAcRzrKujf04NNdM2RxZIACcJBv7EKyGnp7qAfo4eL/iVlI264+bPxXOwHmWZNC0qjyY90xjs4xozTaDl+Qy15A+7SQMQLsozt5OnbiHbjQVkvm8/ywtXDoA45fNft5r7eG6/uTcg+7Nk16gsGJ9Wi8O0SRYwz3Zkmz6TXoEkHjV2a4MJLqQDsKxs8tZ7/l5ChOm7ZlpxgDtT1hN7VUS5g5+ScdJ2HSO+3DjM9Q1+4Oh7CK2kZSoalkQvTaeB6OxsKhoaDM2JuEHTaPVKN8sJTKCIP3zRLOOizXIj1tCn4IgVvmiwMUOpzxlqveJYS7ZQ7+GTZ4wBhHOmuX9FA==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=JBeulich@xxxxxxxx;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Tue, 30 Jul 2019 16:08:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVQoNqxP3NLSDaSUO4Yjwj1hPOv6bjWDkA
  • Thread-topic: [PATCH] tests/cpu-policy: fix format-overflow warning by null terminating strings

On 25.07.2019 02:53, christopher.w.clark@xxxxxxxxx wrote:
> From: Christopher Clark <christopher.w.clark@xxxxxxxxx>
> 
> gcc 9.1.0 reports:
> 
> | test-cpu-policy.c:64:18: error: '%.12s' directive argument is not a 
> nul-terminated string [-Werror=format-overflow=]
> |    64 |             fail("  Test '%.12s', expected vendor %u, got %u\n",
> |       |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> | test-cpu-policy.c:20:12: note: in definition of macro 'fail'
> |    20 |     printf(fmt, ##__VA_ARGS__);                 \
> |       |            ^~~
> | test-cpu-policy.c:64:27: note: format string is defined here
> |    64 |             fail("  Test '%.12s', expected vendor %u, got %u\n",
> |       |                           ^~~~~
> | test-cpu-policy.c:44:7: note: referenced argument declared here
> |    44 |     } tests[] = {
> |       |       ^~~~~

In order to possibly create a bug report against gcc I've tried this:

#include <stdio.h>

struct s {
        char ac[12];
        int i;
};

void test(const struct s*ps) {
        printf("'%.12s'\n", ps->ac);
}

There's no warning here. Could you check whether the compiler warns on
that simple test for you? If it does - are we talking about plain
upstream 9.1.0 (in which case I'd be really puzzled by the difference
in behavior)?

Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.