From b7265da4ccdfe4d256e72dc1b2a0f6b54e087ad2 Mon Sep 17 00:00:00 2001 From: Alessio Balsini Date: Tue, 22 Oct 2019 11:31:05 +0100 Subject: losetup: Change variable name to improve readability Having a dynamic memory pointer named as "s", issuing "free(s)" and then performing "FLAG(s)" is correct: "FLAG(s)" is a macro which uses "s" as a token and expands as "FLAG_s". At a glance, this would instead look like a use-after-free violation. Fix this readability issue by renaming the "s" pointer variable to "f_path". Change-Id: I51f139034a7dcd67a08a6952bc22c1a904162c65 Signed-off-by: Alessio Balsini --- toys/other/losetup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'toys/other') diff --git a/toys/other/losetup.c b/toys/other/losetup.c index 7f91ba1f..27d25a18 100644 --- a/toys/other/losetup.c +++ b/toys/other/losetup.c @@ -103,16 +103,16 @@ static int loopback_setup(char *device, char *file) } // Associate file with this device? } else if (file) { - char *s = xabspath(file, 1); + char *f_path = xabspath(file, 1); - if (!s) perror_exit("file"); // already opened, but if deleted since... + if (!f_path) perror_exit("file"); // already opened, but if deleted since... if (ioctl(lfd, LOOP_SET_FD, ffd)) { - free(s); + free(f_path); if (racy && errno == EBUSY) return 1; perror_exit("%s=%s", device, file); } - xstrncpy((char *)loop->lo_file_name, s, LO_NAME_SIZE); - free(s); + xstrncpy((char *)loop->lo_file_name, f_path, LO_NAME_SIZE); + free(f_path); loop->lo_offset = TT.o; loop->lo_sizelimit = TT.S; if (ioctl(lfd, LOOP_SET_STATUS64, loop)) perror_exit("%s=%s", device, file); -- cgit v1.2.3