]> xenbits.xensource.com Git - libvirt.git/commitdiff
openvz: pass sizeof to snprintf
authorJán Tomko <jtomko@redhat.com>
Tue, 6 Mar 2018 12:56:31 +0000 (13:56 +0100)
committerJán Tomko <jtomko@redhat.com>
Thu, 8 Mar 2018 15:45:54 +0000 (16:45 +0100)
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 <jtomko@redhat.com>
src/openvz/openvz_driver.c

index 9bd73d85c49fa57a40069281ff53774772647cb9..ebdc3890ecbfcc40849595f6ecf3ff64b867ebc7 100644 (file)
@@ -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)