From d3b8a81ae6308cbdc33e43c715295d375d1d28e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Tomko?= Date: Tue, 6 Mar 2018 13:56:31 +0100 Subject: [PATCH] openvz: pass sizeof to snprintf MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The size argument accounts for the nul-byte to terminate the string. Use sizeof and remove the pointless assignment. Signed-off-by: Ján Tomko --- src/openvz/openvz_driver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 9bd73d85c4..ebdc3890ec 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1355,8 +1355,7 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm, if (pcpus > 0 && pcpus < nvcpus) nvcpus = pcpus; - snprintf(str_vcpus, 31, "%d", nvcpus); - str_vcpus[31] = '\0'; + snprintf(str_vcpus, sizeof(str_vcpus), "%d", nvcpus); openvzSetProgramSentinal(prog, vm->def->name); if (virRun(prog, NULL) < 0) -- 2.47.2