From: Ján Tomko Date: Tue, 6 Mar 2018 12:56:31 +0000 (+0100) Subject: openvz: pass sizeof to snprintf X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d3b8a81ae6308cbdc33e43c715295d375d1d28e2;p=libvirt.git openvz: pass sizeof to snprintf 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 --- 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)