From 16e5eb212fb8e054513adafa6c44db23f27dbb46 Mon Sep 17 00:00:00 2001 From: rilysh Date: Thu, 11 Apr 2024 12:23:33 -0600 Subject: [PATCH] fdwrite.c: initialize pointers to NULL and a few other cleanups 1. Both trackbuf and vrfybuf are initialized to zero (NULL). While it's okay to initialize pointers to zero, to keep consistency, as they're explicitly pointers, it's better to just use NULL ((void *)0) instead of 0 (both are equivalent to the compilers). 2. Call free() for both trackbuf and vrfybuf after their job has been done. 3. Remove the register keyword. Compilers generally ignore this keyword (except for very very old compilers and CPUs). 4. Remove the ctype.h header. It's not being used anywhere in the file. Signed-off-by: rilysh Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1059 --- usr.sbin/fdwrite/fdwrite.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.sbin/fdwrite/fdwrite.c b/usr.sbin/fdwrite/fdwrite.c index 4c91ae2599c6..94052028c6dc 100644 --- a/usr.sbin/fdwrite/fdwrite.c +++ b/usr.sbin/fdwrite/fdwrite.c @@ -10,7 +10,6 @@ * */ -#include #include #include #include @@ -26,7 +25,7 @@ format_track(int fd, int cyl, int secs, int head, int rate, int gaplen, int secsize, int fill, int interleave) { struct fd_formb f; - register int i,j; + int i, j; int il[100]; memset(il,0,sizeof il); @@ -68,7 +67,7 @@ main(int argc, char **argv) int bpt, verbose=1, nbytes=0, track; int interactive = 1; const char *device= "/dev/fd0"; - char *trackbuf = 0,*vrfybuf = 0; + char *trackbuf = NULL, *vrfybuf = NULL; struct fd_type fdt; FILE *tty; @@ -192,5 +191,8 @@ main(int argc, char **argv) } if(verbose) printf("%d bytes on %d flopp%s\n",nbytes,fdn,fdn==1?"y":"ies"); + + free(trackbuf); + free(vrfybuf); exit(0); }