git: 16e5eb212fb8 - main - fdwrite.c: initialize pointers to NULL and a few other cleanups
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 11 Apr 2024 18:27:52 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=16e5eb212fb8e054513adafa6c44db23f27dbb46 commit 16e5eb212fb8e054513adafa6c44db23f27dbb46 Author: rilysh <nightquick@proton.me> AuthorDate: 2024-04-11 18:23:33 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-04-11 18:24:36 +0000 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 <nightquick@proton.me> 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 <ctype.h> #include <err.h> #include <fcntl.h> #include <paths.h> @@ -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); }