From: Oliver Kurth Date: Fri, 23 Mar 2018 21:57:12 +0000 (-0700) Subject: [lib/file]: remove useless heap allocation X-Git-Tag: stable-10.3.0~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4eff69adab058331a1e93aee17ed9a4e13fa8714;p=thirdparty%2Fopen-vm-tools.git [lib/file]: remove useless heap allocation FileIO_AtomicUpdateEx allocates the argument to the "swap" ioctl on the heap. This argument is a struct which contains a single int fd... there is no need to heap-allocate it, the stack is just fine. --- diff --git a/open-vm-tools/lib/file/fileIO.c b/open-vm-tools/lib/file/fileIO.c index b053ed232..77ffc0127 100644 --- a/open-vm-tools/lib/file/fileIO.c +++ b/open-vm-tools/lib/file/fileIO.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2017 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2018 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -849,7 +849,7 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD, // IN/OUT: file IO descriptor if (HostType_OSIsVMK()) { #if defined(VMX86_SERVER) - FS_SwapFilesArgsUW *args = NULL; + FS_SwapFilesArgsUW args = { 0 }; char *dirName = NULL; char *fileName = NULL; char *dstDirName = NULL; @@ -890,9 +890,8 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD, // IN/OUT: file IO descriptor goto swapdone; } - args = Util_SafeCalloc(1, sizeof *args); - args->fd = currFD->posix; - if (ioctl(newFD->posix, IOCTLCMD_VMFS_SWAP_FILES, args) != 0) { + args.fd = currFD->posix; + if (ioctl(newFD->posix, IOCTLCMD_VMFS_SWAP_FILES, &args) != 0) { savedErrno = errno; if (errno != ENOSYS && errno != ENOTTY) { Log("%s: ioctl failed %d.\n", __FUNCTION__, errno); @@ -942,7 +941,6 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD, // IN/OUT: file IO descriptor } swapdone: - Posix_Free(args); Posix_Free(dirName); Posix_Free(fileName); Posix_Free(dstDirName);