diff options
author | Toomas Soome <tsoome@me.com> | 2016-07-28 14:16:13 +0300 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2016-08-02 11:17:05 -0700 |
commit | 3bbf88b3546192f29c18986b9fb8a19ff364a4ea (patch) | |
tree | 70e4c55869bf3ecf1b52898b376217fdb89d1f7f | |
parent | b72b6bb10ad55121a1b352c6f68ebdc8e20c9086 (diff) | |
download | illumos-joyent-3bbf88b3546192f29c18986b9fb8a19ff364a4ea.tar.gz |
7242 usr/src/cmd/boot build needs cleanup
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r-- | exception_lists/keywords | 1 | ||||
-rw-r--r-- | usr/src/cmd/boot/bootadm/Makefile | 4 | ||||
-rw-r--r-- | usr/src/cmd/boot/bootadm/bootadm.c | 55 | ||||
-rw-r--r-- | usr/src/cmd/boot/bootadm/bootadm_upgrade.c | 27 | ||||
-rw-r--r-- | usr/src/cmd/boot/common/bblk_einfo.c | 2 | ||||
-rw-r--r-- | usr/src/cmd/boot/filelist/Makefile | 2 | ||||
-rw-r--r-- | usr/src/cmd/boot/fiocompress/Makefile | 7 | ||||
-rw-r--r-- | usr/src/cmd/boot/installboot/Makefile | 4 | ||||
-rw-r--r-- | usr/src/cmd/boot/installgrub/Makefile | 7 | ||||
-rw-r--r-- | usr/src/cmd/boot/installgrub/installgrub.c | 87 | ||||
-rw-r--r-- | usr/src/cmd/boot/installgrub/pcfs_glue.c | 6 | ||||
-rw-r--r-- | usr/src/cmd/boot/mbr/Makefile | 1 | ||||
-rw-r--r-- | usr/src/cmd/boot/mbr/mbr.c | 3 |
13 files changed, 53 insertions, 153 deletions
diff --git a/exception_lists/keywords b/exception_lists/keywords index 632d4e55ff..f0be882342 100644 --- a/exception_lists/keywords +++ b/exception_lists/keywords @@ -26,6 +26,7 @@ syntax: glob usr/src/cmd/cmd-inet/usr.bin/dns-sd/dns-sd.c +usr/src/cmd/boot/common/bblk_einfo.c usr/src/cmd/localedef/data/zh_CN.UTF-8.src usr/src/cmd/localedef/data/zh_HK.UTF-8.src usr/src/cmd/localedef/data/zh_MO.UTF-8.src diff --git a/usr/src/cmd/boot/bootadm/Makefile b/usr/src/cmd/boot/bootadm/Makefile index e3f67930ff..be838e34f7 100644 --- a/usr/src/cmd/boot/bootadm/Makefile +++ b/usr/src/cmd/boot/bootadm/Makefile @@ -46,9 +46,7 @@ CFLAGS += $(XSTRCONST) CPPFLAGS += -D_FILE_OFFSET_BITS=64 CPPFLAGS += -I../../../uts/common -I../../../common -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-uninitialized -CERRWARN += -_gcc=-Wno-unused-label +C99MODE= $(C99_ENABLE) LINTFLAGS += -erroff=E_INCONS_ARG_DECL2 LINTFLAGS += -erroff=E_INCONS_VAL_TYPE_DECL2 diff --git a/usr/src/cmd/boot/bootadm/bootadm.c b/usr/src/cmd/boot/bootadm/bootadm.c index 6e653470f1..ba62ba3d7a 100644 --- a/usr/src/cmd/boot/bootadm/bootadm.c +++ b/usr/src/cmd/boot/bootadm/bootadm.c @@ -536,7 +536,7 @@ sanitize_env() int main(int argc, char *argv[]) { - error_t ret; + error_t ret = BAM_SUCCESS; (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); @@ -1050,11 +1050,11 @@ install_bootloader(void) be_node_list_t *be_nodes, *node; FILE *fp; char *root_ds = NULL; - int ret; + int ret = BAM_ERROR; if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) { bam_error(_("out of memory\n")); - return (BAM_ERROR); + return (ret); } /* @@ -1069,12 +1069,10 @@ install_bootloader(void) if (bam_alt_root) { if (stat(bam_root, &statbuf) != 0) { bam_error(STAT_FAIL, bam_root, strerror(errno)); - ret = BAM_ERROR; goto done; } if ((fp = fopen(MNTTAB, "r")) == NULL) { bam_error(OPEN_FAIL, MNTTAB, strerror(errno)); - ret = BAM_ERROR; goto done; } resetmnttab(fp); @@ -1090,18 +1088,15 @@ install_bootloader(void) if (found == 0) { bam_error(NOT_IN_MNTTAB, bam_root); - ret = BAM_ERROR; goto done; } if (root_ds == NULL) { bam_error(_("out of memory\n")); - ret = BAM_ERROR; goto done; } if (be_list(NULL, &be_nodes) != BE_SUCCESS) { bam_error(_("No BE's found\n")); - ret = BAM_ERROR; goto done; } for (node = be_nodes; node != NULL; node = node->be_next_node) @@ -1115,7 +1110,6 @@ install_bootloader(void) root_ds = NULL; if (node == NULL) { be_free_list(be_nodes); - ret = BAM_ERROR; goto done; } ret = nvlist_add_string(nvl, BE_ATTR_ORIG_BE_NAME, @@ -1123,7 +1117,7 @@ install_bootloader(void) ret |= nvlist_add_string(nvl, BE_ATTR_ORIG_BE_ROOT, node->be_root_ds); be_free_list(be_nodes); - if (ret) { + if (ret != 0) { ret = BAM_ERROR; goto done; } @@ -1138,6 +1132,7 @@ install_bootloader(void) if (nvlist_add_uint16(nvl, BE_ATTR_INSTALL_FLAGS, flags) != 0) { bam_error(_("out of memory\n")); + ret = BAM_ERROR; goto done; } @@ -1148,13 +1143,13 @@ install_bootloader(void) */ if (bam_pool != NULL) { ret = nvlist_add_string(nvl, BE_ATTR_ORIG_BE_POOL, bam_pool); - if (ret) { + if (ret != 0) { ret = BAM_ERROR; goto done; } if (found) { ret = be_installboot(nvl); - if (ret) + if (ret != 0) ret = BAM_ERROR; goto done; } @@ -1187,12 +1182,12 @@ install_bootloader(void) ret |= nvlist_add_string(nvl, BE_ATTR_ORIG_BE_ROOT, node->be_root_ds); be_free_list(be_nodes); - if (ret) { + if (ret != 0) { ret = BAM_ERROR; goto done; } ret = be_installboot(nvl); - if (ret) + if (ret != 0) ret = BAM_ERROR; goto done; } @@ -1249,7 +1244,7 @@ install_bootloader(void) ret |= nvlist_add_string(nvl, BE_ATTR_ORIG_BE_POOL, node->be_rpool); be_free_list(be_nodes); - if (ret) + if (ret != 0) ret = BAM_ERROR; else ret = be_installboot(nvl) ? BAM_ERROR : 0; @@ -1285,10 +1280,10 @@ bam_menu(char *subcmd, char *opt, int largc, char *largv[]) char menu_root[PATH_MAX]; struct stat sb; error_t (*f)(menu_t *mp, char *menu_path, char *opt); - char *special; + char *special = NULL; char *pool = NULL; zfs_mnted_t zmnted; - char *zmntpt; + char *zmntpt = NULL; char *osdev; char *osroot; const char *fcn = "bam_menu()"; @@ -1414,8 +1409,7 @@ bam_menu(char *subcmd, char *opt, int largc, char *largv[]) if ((menu = menu_read(menu_path)) == NULL) { bam_error(CANNOT_LOCATE_GRUB_MENU_FILE, menu_path); - if (special != NULL) - free(special); + free(special); return (BAM_ERROR); } @@ -2259,8 +2253,9 @@ cmpstat( return (0); /* read in list of safe files */ - if (safefiles == NULL) - if (fp = fopen("/boot/solaris/filelist.safe", "r")) { + if (safefiles == NULL) { + fp = fopen("/boot/solaris/filelist.safe", "r"); + if (fp != NULL) { safefiles = s_calloc(1, sizeof (struct safefile)); safefilep = safefiles; @@ -2278,6 +2273,7 @@ cmpstat( } (void) fclose(fp); } + } } /* @@ -2384,11 +2380,12 @@ cmpstat( } } - if (bam_verbose) + if (bam_verbose) { if (bam_smf_check) bam_print(" %s\n", file); else bam_print(PARSEABLE_OUT_DATE, file); + } } return (0); @@ -2408,7 +2405,7 @@ rmdir_r(char *path) if ((dir = opendir(path)) == NULL) return (-1); - while (d = readdir(dir)) { + while ((d = readdir(dir)) != NULL) { if ((strcmp(d->d_name, ".") != 0) && (strcmp(d->d_name, "..") != 0)) { (void) snprintf(tpath, sizeof (tpath), "%s/%s", @@ -4555,6 +4552,7 @@ line_parser(menu_t *mp, char *str, int *lineNum, int *entryNum) menu_flag_t flag = BAM_INVALID; const char *fcn = "line_parser()"; + cmd = NULL; if (str == NULL) { return; } @@ -5315,7 +5313,7 @@ get_grubroot(char *osroot, char *osdev, char *menu_root) { char *grubroot; /* (hd#,#,#) */ char *slice; - char *grubhd; + char *grubhd = NULL; int fdiskpart; int found = 0; char *devname; @@ -5426,7 +5424,7 @@ find_primary_common(char *mntpt, char *fstype) ufs = zfs = lu = NULL; - while (entp = readdir(dirp)) { + while ((entp = readdir(dirp)) != NULL) { if (strcmp(entp->d_name, ".") == 0 || strcmp(entp->d_name, "..") == 0) continue; @@ -6123,8 +6121,7 @@ free_mnttab(mhash_t *mhp) int i; for (i = 0; i < MH_HASH_SZ; i++) { - /*LINTED*/ - while (mcp = mhp->mh_hash[i]) { + while ((mcp = mhp->mh_hash[i]) != NULL) { mhp->mh_hash[i] = mcp->mc_next; free(mcp->mc_special); free(mcp->mc_mntpt); @@ -6637,7 +6634,7 @@ FindAllUfsSignatures(void) goto fail; } - while (dp = readdir(dirp)) { + while ((dp = readdir(dirp)) != NULL) { if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue; @@ -9121,7 +9118,7 @@ get_set_kernel( char *space; char *new_path; char old_space; - size_t old_kernel_len; + size_t old_kernel_len = 0; size_t new_str_len; char *fstype; char *osdev; diff --git a/usr/src/cmd/boot/bootadm/bootadm_upgrade.c b/usr/src/cmd/boot/bootadm/bootadm_upgrade.c index 82ff62a05f..aafff97207 100644 --- a/usr/src/cmd/boot/bootadm/bootadm_upgrade.c +++ b/usr/src/cmd/boot/bootadm/bootadm_upgrade.c @@ -93,7 +93,7 @@ get_findroot_cap(const char *osroot) bam_is_findroot = BAM_FINDROOT_ABSENT; BAM_DPRINTF((D_FINDROOT_ABSENT, fcn)); } -out: + ret = fclose(fp); error = errno; INJECT_ERROR1("GET_CAP_FINDROOT_FCLOSE", ret = 1); @@ -409,7 +409,7 @@ cvt_kernel_line(line_t *line, const char *osroot, entry_t *entry) * * old_ptr is either at "flags1" or "unix" */ - if (unix_ptr = strstr(old_ptr, "/unix")) { + if ((unix_ptr = strstr(old_ptr, "/unix")) != NULL) { /* * There is a unix. @@ -702,12 +702,13 @@ bam_add_findroot(menu_t *mp, char *grubsign, char *grubroot, int root_opt) bam_print(CVT_FINDROOT); - entry = mp->entries; - for (; entry = find_matching_entry(entry, grubsign, grubroot, root_opt); - entry = entry->next) { + entry = find_matching_entry(mp->entries, grubsign, grubroot, root_opt); + while (entry != NULL) { if (entry->flags & BAM_ENTRY_FINDROOT) { /* already converted */ BAM_DPRINTF((D_ALREADY_FINDROOT, fcn, entry->entryNum)); + entry = find_matching_entry(entry->next, grubsign, + grubroot, root_opt); continue; } for (line = entry->start; line; line = line->next) { @@ -747,6 +748,8 @@ bam_add_findroot(menu_t *mp, char *grubsign, char *grubroot, int root_opt) break; } } + entry = find_matching_entry(entry->next, grubsign, grubroot, + root_opt); } if (update_num) { @@ -766,13 +769,14 @@ bam_add_hv(menu_t *mp, char *grubsign, char *grubroot, int root_opt) bam_print(CVT_HV); - entry = mp->entries; - for (; entry = find_matching_entry(entry, grubsign, grubroot, root_opt); - entry = entry->next) { + entry = find_matching_entry(mp->entries, grubsign, grubroot, root_opt); + while (entry != NULL) { if (entry->flags & BAM_ENTRY_HV) { BAM_DPRINTF((D_ALREADY_HV, fcn, entry->entryNum)); return (BAM_SUCCESS); } + entry = find_matching_entry(entry->next, grubsign, grubroot, + root_opt); } (void) add_boot_entry(mp, NEW_HV_ENTRY, grubsign, XEN_MENU, @@ -803,9 +807,8 @@ bam_add_dboot( bam_print(CVT_DBOOT); - entry = mp->entries; - for (; entry = find_matching_entry(entry, grubsign, grubroot, root_opt); - entry = entry->next) { + entry = find_matching_entry(mp->entries, grubsign, grubroot, root_opt); + while (entry != NULL) { for (line = entry->start; line; line = line->next) { if (line->cmd == NULL || line->arg == NULL) { if (line == entry->end) { @@ -857,6 +860,8 @@ bam_add_dboot( break; } } + entry = find_matching_entry(entry->next, grubsign, grubroot, + root_opt); } ret = msg ? BAM_MSG : BAM_SUCCESS; diff --git a/usr/src/cmd/boot/common/bblk_einfo.c b/usr/src/cmd/boot/common/bblk_einfo.c index a8a637e211..99b0ced815 100644 --- a/usr/src/cmd/boot/common/bblk_einfo.c +++ b/usr/src/cmd/boot/common/bblk_einfo.c @@ -189,7 +189,7 @@ print_einfo(uint8_t flags, bblk_einfo_t *einfo, unsigned long bufsize) int i = 0; char *version; boolean_t has_hash = B_FALSE; - unsigned char *hash; + unsigned char *hash = NULL; if (einfo->str_off + einfo->str_size > bufsize) { (void) fprintf(stdout, gettext("String offset %d is beyond the " diff --git a/usr/src/cmd/boot/filelist/Makefile b/usr/src/cmd/boot/filelist/Makefile index 5b195ceace..105cfbe18b 100644 --- a/usr/src/cmd/boot/filelist/Makefile +++ b/usr/src/cmd/boot/filelist/Makefile @@ -22,8 +22,6 @@ # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" -# SUBDIRS = $(MACH) diff --git a/usr/src/cmd/boot/fiocompress/Makefile b/usr/src/cmd/boot/fiocompress/Makefile index 1595b14bec..cf64ed1c6e 100644 --- a/usr/src/cmd/boot/fiocompress/Makefile +++ b/usr/src/cmd/boot/fiocompress/Makefile @@ -22,8 +22,6 @@ # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" -# PROG= fiocompress @@ -41,11 +39,6 @@ LDLIBS += -lz CFLAGS += -I../../../uts/common LINTFLAGS += -I../../../uts/common -# definitions for lint -# until libz is compiled against ON header files (uid/gid) -LINTFLAGS += -erroff=E_INCONS_ARG_DECL2 -LINTFLAGS += -erroff=E_INCONS_VAL_TYPE_DECL2 - all: $(PROG) $(PROG): $(OBJS) diff --git a/usr/src/cmd/boot/installboot/Makefile b/usr/src/cmd/boot/installboot/Makefile index e2fcf37f84..024e277115 100644 --- a/usr/src/cmd/boot/installboot/Makefile +++ b/usr/src/cmd/boot/installboot/Makefile @@ -36,11 +36,9 @@ CPPFLAGS += -I$(SRC)/uts/common LDLIBS += -lmd5 -C99MODE= -xc99=%all -C99LMODE= -Xc99=%all +C99MODE= $(C99_ENABLE) LINTFLAGS += -erroff=E_BAD_PTR_CAST_ALIGN -CERRWARN += -_gcc=-Wno-uninitialized .KEEP_STATE: diff --git a/usr/src/cmd/boot/installgrub/Makefile b/usr/src/cmd/boot/installgrub/Makefile index 5d58bd3200..56dfeac536 100644 --- a/usr/src/cmd/boot/installgrub/Makefile +++ b/usr/src/cmd/boot/installgrub/Makefile @@ -39,9 +39,6 @@ include ../Makefile.com CPPFLAGS += -I$(SRC)/uts/i86pc -I$(SRC)/uts/intel -I$(SRC)/uts/common CPPFLAGS += -I$(SRC)/common/util -CERRWARN += -_gcc=-Wno-unused-label -CERRWARN += -_gcc=-Wno-unused-function -CERRWARN += -_gcc=-Wno-uninitialized LDLIBS += -lmd5 @@ -57,8 +54,8 @@ LINTFLAGS += \ -erroff=E_FUNC_RET_MAYBE_IGNORED2 \ -xerroff=E_NAME_DEF_NOT_USED2 -C99MODE= -xc99=%all -C99LMODE= -Xc99=%all + +C99MODE= $(C99_ENABLE) .KEEP_STATE: diff --git a/usr/src/cmd/boot/installgrub/installgrub.c b/usr/src/cmd/boot/installgrub/installgrub.c index 9611bc8a62..18b8f13cd1 100644 --- a/usr/src/cmd/boot/installgrub/installgrub.c +++ b/usr/src/cmd/boot/installgrub/installgrub.c @@ -103,10 +103,8 @@ static int get_start_sector(ig_device_t *); static int get_disk_fd(ig_device_t *device); static int get_raw_partition_fd(ig_device_t *); static char *get_raw_partition_path(ig_device_t *); -static boolean_t gather_stage2_from_dev(ig_data_t *); static int propagate_bootblock(ig_data_t *, ig_data_t *, char *); static int find_x86_bootpar(struct mboot *, int *, uint32_t *); -static int copy_stage2_to_pcfs(ig_data_t *); static int write_stage2(ig_data_t *); static int write_stage1(ig_data_t *); static void usage(char *); @@ -730,7 +728,7 @@ get_start_sector(ig_device_t *device) uint32_t secnum = 0, numsec = 0; int i, pno, rval, log_part = 0; struct mboot *mboot; - struct ipart *part; + struct ipart *part = NULL; ext_part_t *epp; struct part_info dkpi; struct extpart_info edkpi; @@ -887,8 +885,8 @@ found_part: static int get_disk_fd(ig_device_t *device) { - int i; - char save[2]; + int i = 0; + char save[2] = { '\0', '\0' }; char *end = NULL; assert(device != NULL); @@ -1557,82 +1555,3 @@ get_raw_partition_fd(ig_device_t *device) free(raw); return (BC_SUCCESS); } - -#define TMP_MNTPT "/tmp/installgrub_pcfs" -static int -copy_stage2_to_pcfs(ig_data_t *install) -{ - FILE *mntfp; - int pcfs_fp; - int status = BC_ERROR; - char buf[SECTOR_SIZE]; - char *cp; - struct mnttab mp = {0}, mpref = {0}; - ig_device_t *device = &install->device; - ig_stage2_t *stage2 = &install->stage2; - - /* convert raw to block device name by removing the first 'r' */ - (void) strncpy(buf, device->path, sizeof (buf)); - buf[sizeof (buf) - 1] = 0; - cp = strchr(buf, 'r'); - if (cp == NULL) { - (void) fprintf(stderr, CONVERT_FAIL, device->path); - return (BC_ERROR); - } - do { - *cp = *(cp + 1); - } while (*(++cp)); - - /* get the mount point, if any */ - mntfp = fopen("/etc/mnttab", "r"); - if (mntfp == NULL) { - (void) fprintf(stderr, OPEN_FAIL_FILE, "/etc/mnttab"); - return (BC_ERROR); - } - - mpref.mnt_special = buf; - if (getmntany(mntfp, &mp, &mpref) != 0) { - char cmd[128]; - - /* not mounted, try remount */ - (void) mkdir(TMP_MNTPT, S_IRWXU); - (void) snprintf(cmd, sizeof (cmd), "mount -F pcfs %s %s", - buf, TMP_MNTPT); - (void) system(cmd); - rewind(mntfp); - bzero(&mp, sizeof (mp)); - if (getmntany(mntfp, &mp, &mpref) != 0) { - (void) fprintf(stderr, MOUNT_FAIL, buf); - return (BC_ERROR); - } - } - - (void) snprintf(buf, sizeof (buf), - "%s/boot", mp.mnt_mountp); - (void) mkdir(buf, S_IRWXU); - (void) strcat(buf, "/grub"); - (void) mkdir(buf, S_IRWXU); - - (void) strcat(buf, "/stage2"); - pcfs_fp = open(buf, O_WRONLY | O_CREAT, S_IRWXU); - if (pcfs_fp == -1) { - (void) fprintf(stderr, OPEN_FAIL_FILE, buf); - perror("open:"); - goto out; - } - - /* write stage2 to the pcfs mounted filesystem. */ - if (write(pcfs_fp, stage2->file, stage2->file_size) - != stage2->file_size) { - perror(gettext("Error writing stage2")); - goto out; - } - - status = BC_SUCCESS; -out_fd: - (void) close(pcfs_fp); -out: - (void) umount(TMP_MNTPT); - (void) rmdir(TMP_MNTPT); - return (status); -} diff --git a/usr/src/cmd/boot/installgrub/pcfs_glue.c b/usr/src/cmd/boot/installgrub/pcfs_glue.c index 6a2bd6eafc..d687c02f45 100644 --- a/usr/src/cmd/boot/installgrub/pcfs_glue.c +++ b/usr/src/cmd/boot/installgrub/pcfs_glue.c @@ -157,12 +157,6 @@ pcfs_glue_read(int fd, void *buf, size_t size) return (BRD_READ(bfs_ops, fd, buf, size)); } -static off_t -pcfs_glue_lseek(int fd, off_t addr, int whence) -{ - return (BRD_SEEK(bfs_ops, fd, addr, whence)); -} - /* * Get the blocklist for stage2 */ diff --git a/usr/src/cmd/boot/mbr/Makefile b/usr/src/cmd/boot/mbr/Makefile index 387067cae8..844ee0d758 100644 --- a/usr/src/cmd/boot/mbr/Makefile +++ b/usr/src/cmd/boot/mbr/Makefile @@ -30,7 +30,6 @@ SRCS = $(OBJS:.o=.c) include ../Makefile.com -CERRWARN += -_gcc=-Wno-parentheses CLOBBERFILES = $(BOOTPROG) .KEEP_STATE: diff --git a/usr/src/cmd/boot/mbr/mbr.c b/usr/src/cmd/boot/mbr/mbr.c index 44dd3bf282..e4978d224d 100644 --- a/usr/src/cmd/boot/mbr/mbr.c +++ b/usr/src/cmd/boot/mbr/mbr.c @@ -116,11 +116,12 @@ main(int argc, char *argv[]) mboot = (struct mboot *)boot_sect; for (i = 0; i < FD_NUMPART; i++) { struct ipart *part = (struct ipart *)mboot->parts + i; - if (!list_hd) + if (!list_hd) { if (part->bootid == 128) printf("active "); else printf(" "); + } if (setnew && part->systid == 0x82) { part->systid = 0xbf; sol_part = i; |