mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-18 02:19:39 +00:00
Use NULL instead of 0 for pointers and memory allocation.
malloc and realloc will return NULL pointer if it can't alloc memory. MFC after: 4 weeks
This commit is contained in:
parent
69f2305587
commit
960536b69f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298021
@ -95,7 +95,7 @@ verify_track(int fd, int track, int tracksize)
|
|||||||
|
|
||||||
if (bufsz < tracksize)
|
if (bufsz < tracksize)
|
||||||
buf = realloc(buf, bufsz = tracksize);
|
buf = realloc(buf, bufsz = tracksize);
|
||||||
if (buf == 0)
|
if (buf == NULL)
|
||||||
errx(EX_UNAVAILABLE, "out of memory");
|
errx(EX_UNAVAILABLE, "out of memory");
|
||||||
if (lseek (fd, (long) track * tracksize, 0) < 0)
|
if (lseek (fd, (long) track * tracksize, 0) < 0)
|
||||||
rv = -1;
|
rv = -1;
|
||||||
@ -205,7 +205,7 @@ main(int argc, char **argv)
|
|||||||
if (stat(argv[optind], &sb) == -1 && errno == ENOENT) {
|
if (stat(argv[optind], &sb) == -1 && errno == ENOENT) {
|
||||||
/* try prepending _PATH_DEV */
|
/* try prepending _PATH_DEV */
|
||||||
device = malloc(strlen(argv[optind]) + sizeof(_PATH_DEV) + 1);
|
device = malloc(strlen(argv[optind]) + sizeof(_PATH_DEV) + 1);
|
||||||
if (device == 0)
|
if (device == NULL)
|
||||||
errx(EX_UNAVAILABLE, "out of memory");
|
errx(EX_UNAVAILABLE, "out of memory");
|
||||||
strcpy(device, _PATH_DEV);
|
strcpy(device, _PATH_DEV);
|
||||||
strcat(device, argv[optind]);
|
strcat(device, argv[optind]);
|
||||||
@ -252,7 +252,7 @@ main(int argc, char **argv)
|
|||||||
if (format) {
|
if (format) {
|
||||||
getname(type, &name, &descr);
|
getname(type, &name, &descr);
|
||||||
fdtp = get_fmt(format, type);
|
fdtp = get_fmt(format, type);
|
||||||
if (fdtp == 0)
|
if (fdtp == NULL)
|
||||||
errx(EX_USAGE,
|
errx(EX_USAGE,
|
||||||
"unknown format %d KB for drive type %s",
|
"unknown format %d KB for drive type %s",
|
||||||
format, name);
|
format, name);
|
||||||
|
Loading…
Reference in New Issue
Block a user