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 <jtomko@redhat.com>
This commit is contained in:
Ján Tomko 2018-03-06 13:56:31 +01:00
parent 1efdab281f
commit d3b8a81ae6

View 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)