All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: xen-devel@lists.xen.org
Cc: "Wei Liu" <wei.liu2@citrix.com>,
	"Ian Jackson" <ian.jackson@eu.citrix.com>,
	"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
Subject: [PATCH 1/7] tools/libxc: fix strncpy size
Date: Thu,  5 Apr 2018 03:50:49 +0200	[thread overview]
Message-ID: <c7eaf90c2a3f6d7e6c0b1de2ec78fbac5a48b340.1522893038.git-series.marmarek@invisiblethingslab.com> (raw)
In-Reply-To: <cover.c71341b28191a3808896e82914eb11c1472687b2.1522893038.git-series.marmarek@invisiblethingslab.com>
In-Reply-To: <cover.c71341b28191a3808896e82914eb11c1472687b2.1522893038.git-series.marmarek@invisiblethingslab.com>

gcc-8 warns about possible truncation of trailing '\0'.
Final character is overridden by '\0' anyway, so don't bother to copy
it.

This fixes compile failure:

    xc_pm.c: In function 'xc_set_cpufreq_gov':
    xc_pm.c:308:5: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
         strncpy(scaling_governor, govname, CPUFREQ_NAME_LEN);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 tools/libxc/xc_pm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxc/xc_pm.c b/tools/libxc/xc_pm.c
index 67e2418..6f8d548 100644
--- a/tools/libxc/xc_pm.c
+++ b/tools/libxc/xc_pm.c
@@ -305,7 +305,7 @@ int xc_set_cpufreq_gov(xc_interface *xch, int cpuid, char *govname)
     sysctl.cmd = XEN_SYSCTL_pm_op;
     sysctl.u.pm_op.cmd = SET_CPUFREQ_GOV;
     sysctl.u.pm_op.cpuid = cpuid;
-    strncpy(scaling_governor, govname, CPUFREQ_NAME_LEN);
+    strncpy(scaling_governor, govname, CPUFREQ_NAME_LEN - 1);
     scaling_governor[CPUFREQ_NAME_LEN - 1] = '\0';
 
     return xc_sysctl(xch, &sysctl);
-- 
git-series 0.9.1

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

  reply	other threads:[~2018-04-05  1:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05  1:50 [PATCH 0/7] Fix warnings found by gcc 8 Marek Marczykowski-Górecki
2018-04-05  1:50 ` Marek Marczykowski-Górecki [this message]
2018-04-05  1:50 ` [PATCH 2/7] tools/misc: fix hypothetical buffer overflow in xen-lowmemd Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 3/7] tools/blktap2: fix hypothetical buffer overflow Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 4/7] tools/blktap2: fix possible '\0' truncation Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 5/7] tools/xenpmd: " Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 6/7] tools/gdbsx: fix -Wstringop-truncation warning Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 7/7] tools/kdd: mute spurious gcc warning Marek Marczykowski-Górecki
2018-04-06 12:39   ` Boris Ostrovsky
2018-04-06 13:07     ` Wei Liu
2018-04-06 13:39       ` Boris Ostrovsky
2018-04-06 13:41         ` Wei Liu
2018-04-06 13:56           ` Boris Ostrovsky
2018-04-06 14:32             ` Marek Marczykowski-Górecki
2018-04-06 15:12               ` Wei Liu
2018-04-06 15:32                 ` [PATCH] tools/kdd: use mute -Warray-bounds only on new gcc version Marek Marczykowski-Górecki
2018-04-06 17:12                   ` Wei Liu
2018-04-06 22:39                     ` Marek Marczykowski-Górecki
2018-04-07  7:36                       ` Tim Deegan
2018-04-06 17:03               ` [PATCH 7/7] tools/kdd: mute spurious gcc warning Tim Deegan
2018-04-05  9:03 ` [PATCH 0/7] Fix warnings found by gcc 8 Wei Liu
2018-04-05 12:49   ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c7eaf90c2a3f6d7e6c0b1de2ec78fbac5a48b340.1522893038.git-series.marmarek@invisiblethingslab.com \
    --to=marmarek@invisiblethingslab.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.