summaryrefslogtreecommitdiff
path: root/usr/src/cmd/format
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2019-01-24 15:06:01 +0200
committerToomas Soome <tsoome@me.com>2019-07-11 18:16:35 +0300
commit4d7452f8473ff4636be68c3aa2ec185d6aa00315 (patch)
treef2c0130ccd853b52e0d12f95d59af993b7453c50 /usr/src/cmd/format
parente6aecaeeb5918142935e45d37651ac1c267d8e2a (diff)
downloadillumos-joyent-4d7452f8473ff4636be68c3aa2ec185d6aa00315.tar.gz
11338 format: NULL pointer errors
Reviewed by: Andrew Stormont <andyjstormont@gmail.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/cmd/format')
-rw-r--r--usr/src/cmd/format/checkdev.c16
-rw-r--r--usr/src/cmd/format/io.c6
-rw-r--r--usr/src/cmd/format/ix_altsctr.c28
3 files changed, 23 insertions, 27 deletions
diff --git a/usr/src/cmd/format/checkdev.c b/usr/src/cmd/format/checkdev.c
index b1d84ce195..94476bac91 100644
--- a/usr/src/cmd/format/checkdev.c
+++ b/usr/src/cmd/format/checkdev.c
@@ -58,17 +58,17 @@
/* Function prototypes */
#ifdef __STDC__
-static struct swaptable *getswapentries(void);
-static void freeswapentries(struct swaptable *);
+static struct swaptable *getswapentries(void);
+static void freeswapentries(struct swaptable *);
static int getpartition(char *pathname);
-static int checkpartitions(int bm_mounted);
+static int checkpartitions(int bm_mounted);
#else /* __STDC__ */
static struct swaptable *getswapentries();
static void freeswapentries();
static int getpartition();
-static int checkpartitions();
+static int checkpartitions();
#endif /* __STDC__ */
@@ -273,10 +273,10 @@ checkdevinuse(char *cur_disk_path, diskaddr_t start, diskaddr_t end, int print,
int check_label)
{
- int error;
- int found = 0;
+ int error;
+ int found = 0;
int check = 0;
- int i;
+ int i;
int bm_inuse = 0;
int part = 0;
uint64_t slice_start, slice_size;
@@ -353,7 +353,7 @@ checkdevinuse(char *cur_disk_path, diskaddr_t start, diskaddr_t end, int print,
if (slices == NULL)
return (found);
- for (i = 0; slices[i] != NULL; i++) {
+ for (i = 0; slices[i] != 0; i++) {
/*
* If we are checking the whole disk
* then any and all in use data is
diff --git a/usr/src/cmd/format/io.c b/usr/src/cmd/format/io.c
index e98589c5b8..7fd8baf6bc 100644
--- a/usr/src/cmd/format/io.c
+++ b/usr/src/cmd/format/io.c
@@ -2425,9 +2425,7 @@ get_inputline(line, nbytes)
* execute the shell escape command
*/
int
-execute_shell(s, buff_size)
- char *s;
- size_t buff_size;
+execute_shell(char *s, size_t buff_size)
{
struct termio termio;
struct termios tty;
@@ -2437,7 +2435,7 @@ execute_shell(s, buff_size)
tty_flag = -1;
- if (*s == NULL) {
+ if (*s == '\0') {
shell_name = getenv("SHELL");
if (shell_name == NULL) {
diff --git a/usr/src/cmd/format/ix_altsctr.c b/usr/src/cmd/format/ix_altsctr.c
index 03770bc422..d90847cdf3 100644
--- a/usr/src/cmd/format/ix_altsctr.c
+++ b/usr/src/cmd/format/ix_altsctr.c
@@ -112,8 +112,7 @@ struct dkl_partition *part;
* -- read the alternate sector partition tables
*/
int
-read_altsctr(part)
-struct dkl_partition *part;
+read_altsctr(struct dkl_partition *part)
{
if (ap->ap_tblp == NULL) {
/* allocate buffer for the alts partition table (sector size) */
@@ -126,7 +125,7 @@ struct dkl_partition *part;
}
/* allocate buffer for the alts partition map (sector size) */
-/* buffers include the disk image bit map */
+/* buffers include the disk image bit map */
/* and the incore transformed char map */
if ((ap->ap_memmapp = (uchar_t *)malloc(part->p_size)) == NULL) {
@@ -271,7 +270,7 @@ init_altsctr()
ap->ap_tblp->alts_map_base =
altsmap_alloc(ap->ap_tbl_secsiz / NBPSCTR,
ap->part.p_size, ap->ap_map_sectot, ALTS_MAP_UP);
- if (ap->ap_tblp->alts_map_base == NULL) {
+ if (ap->ap_tblp->alts_map_base == 0) {
perror("Unable to allocate alternate map on disk: ");
return (57);
}
@@ -282,10 +281,10 @@ init_altsctr()
/*
- * read the alternate partition tables from disk
+ * read the alternate partition tables from disk
*/
static int
-get_altsctr()
+get_altsctr(void)
{
int mystatus = FAILURE;
int status = 0;
@@ -496,7 +495,7 @@ gen_alts_ent() {
altsmap_alloc((blkaddr_t)ap->ap_tblp->alts_map_base +
ap->ap_map_sectot, (blkaddr_t)ap->part.p_size,
ap->ap_ent_secsiz / NBPSCTR, ALTS_MAP_UP);
- if (ap->ap_tblp->alts_ent_base == NULL) {
+ if (ap->ap_tblp->alts_ent_base == 0) {
perror("Unable to allocate alternate entry table on disk: ");
return (65);
}
@@ -527,7 +526,7 @@ assign_altsctr()
alts_ind =
altsmap_alloc(ap->part.p_size-1, ap->ap_tblp->alts_map_base +
ap->ap_map_sectot - 1, cluster, ALTS_MAP_DOWN);
- if (alts_ind == NULL) {
+ if (alts_ind == 0) {
(void) fprintf(stderr,
"Unable to allocate alternates for bad starting sector %u.\n",
(ap->ap_entp)[i].bad_start);
@@ -547,9 +546,9 @@ assign_altsctr()
* transform the disk image alts bit map to incore char map
*/
static void
-expand_map()
+expand_map(void)
{
- int i;
+ int i;
for (i = 0; i < ap->part.p_size; i++) {
(ap->ap_memmapp)[i] = altsmap_getbit(i);
@@ -560,10 +559,9 @@ expand_map()
* transform the incore alts char map to the disk image bit map
*/
static void
-compress_map()
+compress_map(void)
{
-
- int i;
+ int i;
int bytesz;
char mask = 0;
int maplen = 0;
@@ -631,13 +629,13 @@ int dir;
return (first_ind);
}
- return (NULL);
+ return (0);
}
/*
- * bubble sort the entry table into ascending order
+ * bubble sort the entry table into ascending order
*/
static void
ent_sort(buf, cnt)