diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-06-12 11:46:31 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-06-12 11:46:31 +0000 |
| commit | 8002820af5bd08062d2e43f47ec210a5537c75d5 (patch) | |
| tree | 380f69af0e8840dd3e79a560889e32e3aa54af97 | |
| parent | 6f5a7120f5302fa9ed9499833f5ce780419fea22 (diff) | |
| parent | 32d56ddc1c38ba72380fb34cf6b2cea48f5bd414 (diff) | |
| download | illumos-joyent-8002820af5bd08062d2e43f47ec210a5537c75d5.tar.gz | |
[illumos-gate merge]
commit 32d56ddc1c38ba72380fb34cf6b2cea48f5bd414
8327 logadm: misleading-indentation
commit abedfe964699708e27107aa91adfbbd7d8a6a5b4
8325 luxadm: misleading-indentation
commit f600977f942717123ad27ccbe25fcbb5e830ca1b
8338 format: misleading-indentation
commit 6f2302d279a7dc8c31e7bae29eee66e95743b74e
8173 workaround qemu-xhci HCIVERSION bug
commit 8b0dcb133967b853a15366312ca67b3408be89fd
8321 passmgmt: misleading-indentation
commit f55f1fcb216cf1d45157402e5acbdd70e6fb23f4
8314 tbl: misleading-indentation
commit a4771893ade3c706ccf9e2b441c8fb5d405be3a1
8315 sendmail: misleading-indentation
commit 88811dae72594322206feacfdd588136aca40d65
8287 arn: misleading-indentation
commit 15a0c3a7ba78a992f7bad7c25b74c4a6b91b7ff4
8320 regcmp: misleading-indentation
commit 5b0d4055542d02d79e8b2cd0079f0580027f87e4
8340 datadm: self-comparison always evaluates to false
commit 3ad44b67f5f834e6fb4458edfb33a794a6576451
8333 idmap: misleading-indentation
commit 2597f9c4ddb11e61fb39cb6ff30c2d262ab22bff
8130 loader: enable BE menu if we have BE list
commit 760a3dc429d80e72277b67bec8135d2d185efe9a
8129 bootadm: add support for non-zfs boot entries in menu.lst
8226 missing boot environments cause bootadm list-menu to segfault
| -rw-r--r-- | usr/src/boot/sys/boot/forth/menu.rc | 4 | ||||
| -rw-r--r-- | usr/src/cmd/boot/bootadm/Makefile | 2 | ||||
| -rw-r--r-- | usr/src/cmd/boot/bootadm/bootadm_loader.c | 394 | ||||
| -rw-r--r-- | usr/src/cmd/datadm/datadm.c | 8 | ||||
| -rw-r--r-- | usr/src/cmd/format/menu_command.c | 3 | ||||
| -rw-r--r-- | usr/src/cmd/idmap/idmap/namemaps.c | 3 | ||||
| -rw-r--r-- | usr/src/cmd/logadm/main.c | 6 | ||||
| -rw-r--r-- | usr/src/cmd/luxadm/adm.c | 8 | ||||
| -rw-r--r-- | usr/src/cmd/passmgmt/passmgmt.c | 14 | ||||
| -rw-r--r-- | usr/src/cmd/regcmp/regcmp.c | 25 | ||||
| -rw-r--r-- | usr/src/cmd/sendmail/aux/vacation.c | 9 | ||||
| -rw-r--r-- | usr/src/cmd/tbl/t7.c | 6 | ||||
| -rw-r--r-- | usr/src/uts/common/io/arn/arn_rc.c | 6 | ||||
| -rw-r--r-- | usr/src/uts/common/io/usb/hcd/xhci/xhci.c | 13 | ||||
| -rw-r--r-- | usr/src/uts/common/sys/usb/hcd/xhci/xhcireg.h | 4 |
15 files changed, 282 insertions, 223 deletions
diff --git a/usr/src/boot/sys/boot/forth/menu.rc b/usr/src/boot/sys/boot/forth/menu.rc index bd16193597..d84c5b4430 100644 --- a/usr/src/boot/sys/boot/forth/menu.rc +++ b/usr/src/boot/sys/boot/forth/menu.rc @@ -173,12 +173,12 @@ set optionstoggled_ansi[8]="^[1mD^[mebug....... ^[32;7mOn^[m" \ BOOT ENVIRONMENT MENU \ -\ the BE list is read from pool/boot/menu.lst, the list in file +\ the BE list is read from [pool]/boot/menu.lst, the list in file \ is ordered from oldest to most recent. \ the BE menu will list entries from most recent to oldest, \ so the first page in menu is last page in menu.lst -s" currdev" getenv drop 4 s" zfs:" compare 0= be-pages and [if] +be-pages [if] set zfs_be_currpage=1 be-set-page \ set page data set menuset_name3="bootenv" diff --git a/usr/src/cmd/boot/bootadm/Makefile b/usr/src/cmd/boot/bootadm/Makefile index f910d69f64..ad060b375c 100644 --- a/usr/src/cmd/boot/bootadm/Makefile +++ b/usr/src/cmd/boot/bootadm/Makefile @@ -43,7 +43,7 @@ POFILE= bootadm_cmd.po LDLIBS_i386= -lfdisk LDLIBS += -lficl-sys -lmd -lcryptoutil -lnvpair -lgen -ladm -lefi -LDLIBS += -lz -lbe -lzfs $(LDLIBS_$(MACH)) +LDLIBS += -lz -lbe -lzfs -lofmt $(LDLIBS_$(MACH)) # Writing into string literals is incorrect. We need to match gcc's # behavior, which causes us to take SIGSEGV on such a write. diff --git a/usr/src/cmd/boot/bootadm/bootadm_loader.c b/usr/src/cmd/boot/bootadm/bootadm_loader.c index 2c7382a11c..29db098006 100644 --- a/usr/src/cmd/boot/bootadm/bootadm_loader.c +++ b/usr/src/cmd/boot/bootadm/bootadm_loader.c @@ -46,6 +46,7 @@ #include <libbe.h> #include <ficl.h> #include <ficlplatform/emu.h> +#include <ofmt.h> #include "bootadm.h" @@ -60,12 +61,14 @@ extern char *bam_root; #define TRANSIENT BOOT_DIR "/transient.conf" #define XEN_CONFIG CONF_DIR "/xen" -struct menu_entry { - int entry; - char *title; - char *bootfs; - STAILQ_ENTRY(menu_entry) next; -}; +typedef struct menu_entry { + int me_idx; + boolean_t me_active; + char *me_title; + char *me_type; + char *me_bootfs; + STAILQ_ENTRY(menu_entry) me_next; +} menu_entry_t; STAILQ_HEAD(menu_lst, menu_entry); static error_t set_option(struct menu_lst *, char *, char *); @@ -88,57 +91,67 @@ static subcmd_defn_t menu_subcmds[] = { NULL, 0, NULL, 0 /* must be last */ }; -#define NUM_COLS (4) -struct col_info { - const char *col_name; - size_t width; -}; - -/* - * all columns output format - */ -struct hdr_info { - struct col_info cols[NUM_COLS]; -}; +#define NUM_COLS (5) -static void -print_hdr(struct hdr_info *hdr_info) +static boolean_t +print_menu_cb(ofmt_arg_t *ofarg, char *buf, uint_t bufsize) { - boolean_t first = B_TRUE; - size_t i; - - for (i = 0; i < NUM_COLS; i++) { - struct col_info *col_info = &hdr_info->cols[i]; - const char *name = col_info->col_name; - size_t width = col_info->width; - - if (name == NULL) - continue; - - if (first) { - (void) printf("%-*s", width, name); - first = B_FALSE; - } else - (void) printf(" %-*s", width, name); + menu_entry_t *entry = ofarg->ofmt_cbarg; + + switch (ofarg->ofmt_id) { + case 0: + (void) snprintf(buf, bufsize, "%d", entry->me_idx); + break; + case 1: + (void) snprintf(buf, bufsize, "%s", entry->me_title); + break; + case 2: + (void) snprintf(buf, bufsize, "%s", entry->me_bootfs); + break; + case 3: + (void) snprintf(buf, bufsize, "%s", entry->me_type); + break; + case 4: + if (entry->me_active == B_TRUE) + (void) snprintf(buf, bufsize, " *"); + else + (void) snprintf(buf, bufsize, " -"); + break; + default: + return (B_FALSE); } - (void) putchar('\n'); + return (B_TRUE); } static void -init_hdr_cols(struct hdr_info *hdr) +init_hdr_cols(ofmt_field_t *hdr) { - struct col_info *col = hdr->cols; - size_t i; - - col[0].col_name = _("Index"); - col[1].col_name = _("Default"); - col[2].col_name = _("Dataset"); - col[3].col_name = _("Menu"); - col[4].col_name = NULL; + uint_t i; for (i = 0; i < NUM_COLS; i++) { - const char *name = col[i].col_name; - col[i].width = 0; + char *name = NULL; + + switch (i) { + case 0: + name = _("INDEX"); + break; + case 1: + name = _("NAME"); + break; + case 2: + name = _("DEVICE"); + break; + case 3: + name = _("TYPE"); + break; + case 4: + name = _("DEFAULT"); + break; + } + + hdr[i].of_name = name; + hdr[i].of_id = i; + hdr[i].of_cb = print_menu_cb; if (name != NULL) { wchar_t wname[128]; @@ -147,94 +160,121 @@ init_hdr_cols(struct hdr_info *hdr) if (sz > 0) { int wcsw = wcswidth(wname, sz); if (wcsw > 0) - col[i].width = wcsw; + hdr[i].of_width = wcsw; else - col[i].width = sz; + hdr[i].of_width = sz; } else { - col[i].width = strlen(name); + hdr[i].of_width = strlen(name); } } } } static void -count_widths(struct hdr_info *hdr, struct menu_lst *menu) +menu_update_widths(ofmt_field_t *hdr, struct menu_lst *menu) { size_t len[NUM_COLS]; - struct menu_entry *entry; + menu_entry_t *entry; int i; for (i = 0; i < NUM_COLS; i++) - len[i] = hdr->cols[i].width + 1; + len[i] = hdr[i].of_width + 1; + + STAILQ_FOREACH(entry, menu, me_next) { + size_t entry_len; + + entry_len = strlen(entry->me_title) + 1; + if (entry_len > len[1]) + len[1] = entry_len; - STAILQ_FOREACH(entry, menu, next) { - size_t bootfs_len = strlen(entry->bootfs); - if (bootfs_len > len[2]) - len[2] = bootfs_len + 1; + entry_len = strlen(entry->me_bootfs) + 1; + if (entry_len > len[2]) + len[2] = entry_len; + + entry_len = strlen(entry->me_type) + 1; + if (entry_len > len[3]) + len[3] = entry_len; } for (i = 0; i < NUM_COLS; i++) - hdr->cols[i].width = len[i]; + hdr[i].of_width = len[i]; +} + +static ofmt_field_t * +init_menu_template(struct menu_lst *menu) +{ + ofmt_field_t *temp; + + if ((temp = calloc(NUM_COLS + 1, sizeof (ofmt_field_t))) == NULL) + return (temp); + + init_hdr_cols(temp); + menu_update_widths(temp, menu); + return (temp); } static void -print_menu_nodes(boolean_t parsable, struct hdr_info *hdr, - struct menu_lst *menu) +print_nodes(boolean_t parsable, struct menu_lst *menu) { - struct menu_entry *entry; - int i = -1; - int rv; - be_node_list_t *be_nodes, *be_node; + ofmt_status_t oferr; + ofmt_handle_t ofmt; + uint_t ofmtflags = 0; + ofmt_field_t *menu_template; + menu_entry_t *entry; - rv = be_list(NULL, &be_nodes); - if (rv != BE_SUCCESS) - return; + if (parsable == B_TRUE) + ofmtflags = OFMT_PARSABLE; - STAILQ_FOREACH(entry, menu, next) { - i++; - for (be_node = be_nodes; be_node; - be_node = be_node->be_next_node) - if (strcmp(be_node->be_root_ds, entry->bootfs) == 0) - break; + menu_template = init_menu_template(menu); + oferr = ofmt_open(NULL, menu_template, ofmtflags, 0, &ofmt); - if (parsable) - (void) printf("%d;%s;%s;%s\n", i, - be_node->be_active_on_boot == B_TRUE? "*" : "-", - entry->bootfs, entry->title); - else - (void) printf("%-*d %-*s %-*s %-*s\n", - hdr->cols[0].width, i, - hdr->cols[1].width, - be_node->be_active_on_boot == B_TRUE? "*" : "-", - hdr->cols[2].width, entry->bootfs, - hdr->cols[3].width, entry->title); + if (oferr != OFMT_SUCCESS) { + char buf[OFMT_BUFSIZE]; + + (void) ofmt_strerror(ofmt, oferr, buf, sizeof (buf)); + (void) printf("bootadm: %s\n", buf); + free(menu_template); + return; } - be_free_list(be_nodes); + + STAILQ_FOREACH(entry, menu, me_next) + ofmt_print(ofmt, entry); + + ofmt_close(ofmt); + free(menu_template); } -static void -print_nodes(boolean_t parsable, struct menu_lst *menu) +/* + * Get the be_active_on_boot for bootfs. + */ +static boolean_t +menu_active_on_boot(be_node_list_t *be_nodes, const char *bootfs) { - struct hdr_info hdr; + be_node_list_t *be_node; + boolean_t rv = B_FALSE; - if (!parsable) { - init_hdr_cols(&hdr); - count_widths(&hdr, menu); - print_hdr(&hdr); + for (be_node = be_nodes; be_node != NULL; + be_node = be_node->be_next_node) { + if (strcmp(be_node->be_root_ds, bootfs) == 0) { + rv = be_node->be_active_on_boot; + break; + } } - print_menu_nodes(parsable, &hdr, menu); + return (rv); } error_t menu_read(struct menu_lst *menu, char *menu_path) { FILE *fp; - struct menu_entry *mp; + be_node_list_t *be_nodes; + menu_entry_t *mp; char buf[PATH_MAX]; char *title; char *bootfs; - char *ptr; + char *type; + char *key, *value; int i = 0; int ret = BAM_SUCCESS; @@ -242,87 +282,82 @@ menu_read(struct menu_lst *menu, char *menu_path) if (fp == NULL) return (BAM_ERROR); + if (be_list(NULL, &be_nodes) != BE_SUCCESS) + be_nodes = NULL; + /* * menu.lst entry is on two lines, one for title, one for bootfs * so we process both lines in succession. */ + title = NULL; + type = NULL; + bootfs = NULL; do { if (fgets(buf, PATH_MAX, fp) == NULL) { if (!feof(fp)) ret = BAM_ERROR; - (void) fclose(fp); - return (ret); - } - ptr = strchr(buf, '\n'); - if (ptr != NULL) - *ptr = '\0'; - - ptr = strchr(buf, ' '); - if (ptr == NULL) { - (void) fclose(fp); - return (BAM_ERROR); + goto done; } - *ptr++ = '\0'; - if (strcmp(buf, "title") != 0) { - (void) fclose(fp); - return (BAM_ERROR); + key = strtok(buf, " \n"); + if (strcmp(key, "title") != 0) { + ret = BAM_ERROR; + goto done; } - if ((title = strdup(ptr)) == NULL) { - (void) fclose(fp); - return (BAM_ERROR); + value = strtok(NULL, " \n"); + if ((title = strdup(value)) == NULL) { + ret = BAM_ERROR; + goto done; } if (fgets(buf, PATH_MAX, fp) == NULL) { - free(title); - (void) fclose(fp); - return (BAM_ERROR); + ret = BAM_ERROR; + goto done; } - ptr = strchr(buf, '\n'); - if (ptr != NULL) - *ptr = '\0'; - - ptr = strchr(buf, ' '); - if (ptr == NULL) { - free(title); - (void) fclose(fp); - return (BAM_ERROR); - } - *ptr++ = '\0'; - if (strcmp(buf, "bootfs") != 0) { - free(title); - (void) fclose(fp); - return (BAM_ERROR); + key = strtok(buf, " \n"); + if ((type = strdup(key)) == NULL) { + ret = BAM_ERROR; + goto done; } - if ((bootfs = strdup(ptr)) == NULL) { - free(title); - (void) fclose(fp); - return (BAM_ERROR); + value = strtok(NULL, " \n"); + if ((bootfs = strdup(value)) == NULL) { + ret = BAM_ERROR; + goto done; } - if ((mp = malloc(sizeof (struct menu_entry))) == NULL) { - free(title); - free(bootfs); - (void) fclose(fp); - return (BAM_ERROR); + if ((mp = malloc(sizeof (menu_entry_t))) == NULL) { + ret = BAM_ERROR; + goto done; } - mp->entry = i++; - mp->title = title; - mp->bootfs = bootfs; - STAILQ_INSERT_TAIL(menu, mp, next); + mp->me_idx = i++; + mp->me_title = title; + mp->me_type = type; + mp->me_bootfs = bootfs; + mp->me_active = menu_active_on_boot(be_nodes, bootfs); + STAILQ_INSERT_TAIL(menu, mp, me_next); + + title = NULL; + type = NULL; + bootfs = NULL; } while (feof(fp) == 0); +done: + free(title); + free(type); + free(bootfs); (void) fclose(fp); + be_free_list(be_nodes); return (ret); } void menu_free(struct menu_lst *menu) { - struct menu_entry *entry; - STAILQ_FOREACH(entry, menu, next) { - STAILQ_REMOVE_HEAD(menu, next); - free(entry->title); - free(entry->bootfs); + menu_entry_t *entry; + STAILQ_FOREACH(entry, menu, me_next) { + STAILQ_REMOVE_HEAD(menu, me_next); + free(entry->me_title); + free(entry->me_type); + free(entry->me_bootfs); free(entry); } } @@ -566,7 +601,7 @@ set_option(struct menu_lst *menu, char *dummy, char *opt) char *val; char *rest; int optval; - struct menu_entry *entry; + menu_entry_t *entry; nvlist_t *be_attrs; FILE *fp; int rv, ret = BAM_SUCCESS; @@ -587,8 +622,8 @@ set_option(struct menu_lst *menu, char *dummy, char *opt) bam_error(_("invalid boot entry number: %s\n"), val); return (BAM_ERROR); } - STAILQ_FOREACH(entry, menu, next) { - if (entry->entry == optval) + STAILQ_FOREACH(entry, menu, me_next) { + if (entry->me_idx == optval) break; } if (entry == NULL) { @@ -600,7 +635,7 @@ set_option(struct menu_lst *menu, char *dummy, char *opt) return (BAM_ERROR); } if (nvlist_add_string(be_attrs, BE_ATTR_ORIG_BE_NAME, - entry->title) != 0) { + entry->me_title) != 0) { bam_error(_("out of memory\n")); nvlist_free(be_attrs); return (BAM_ERROR); @@ -660,7 +695,7 @@ set_option(struct menu_lst *menu, char *dummy, char *opt) } static int -bam_mount_be(struct menu_entry *entry, char **dir) +bam_mount_be(menu_entry_t *entry, char **dir) { nvlist_t *be_attrs = NULL; const char *tmpdir = getenv("TMPDIR"); @@ -690,7 +725,7 @@ bam_mount_be(struct menu_entry *entry, char **dir) for (be_node = be_nodes; be_node; be_node = be_node->be_next_node) - if (strcmp(be_node->be_root_ds, entry->bootfs) == 0) + if (strcmp(be_node->be_root_ds, entry->me_bootfs) == 0) break; if (nvlist_add_string(be_attrs, BE_ATTR_ORIG_BE_NAME, @@ -747,7 +782,7 @@ out: * display details of menu entry or single property */ static error_t -list_menu_entry(struct menu_entry *entry, char *setting) +list_menu_entry(menu_entry_t *entry, char *setting) { int ret = BAM_SUCCESS; char *ptr, *dir; @@ -755,13 +790,21 @@ list_menu_entry(struct menu_entry *entry, char *setting) ficlVm *vm; int mounted; + if (strcmp(entry->me_type, "bootfs") != 0 || + strchr(entry->me_bootfs, ':') != NULL) { + (void) printf("\nTitle: %s\n", entry->me_title); + (void) printf("Type: %s\n", entry->me_type); + (void) printf("Device: %s\n", entry->me_bootfs); + return (ret); + } + mounted = bam_mount_be(entry, &dir); if (mounted != BE_SUCCESS && mounted != BE_ERR_MOUNTED) { if (dir != NULL) { (void) rmdir(dir); free(dir); } - bam_error(_("%s is not mounted\n"), entry->title); + bam_error(_("%s is not mounted\n"), entry->me_title); return (BAM_ERROR); } @@ -774,7 +817,7 @@ list_menu_entry(struct menu_entry *entry, char *setting) /* should only get FICL_VM_STATUS_OUT_OF_TEXT */ (void) snprintf(buf, MAX_INPUT, "set currdev=zfs:%s:", - entry->bootfs); + entry->me_bootfs); ret = ficlVmEvaluate(vm, buf); if (ret != FICL_VM_STATUS_OUT_OF_TEXT) { bam_error(_("error interpreting boot config\n")); @@ -805,9 +848,9 @@ list_menu_entry(struct menu_entry *entry, char *setting) ret = BAM_SUCCESS; if (*setting == '\0') - (void) printf("\nTitle: %s\n", entry->title); + (void) printf("\nTitle: %s\n", entry->me_title); else if (strcasecmp(setting, "title") == 0) { - (void) printf("%s\n", entry->title); + (void) printf("%s\n", entry->me_title); goto done; } @@ -837,9 +880,9 @@ list_menu_entry(struct menu_entry *entry, char *setting) } if (*setting == '\0') - (void) printf("Bootfs: %s\n", entry->bootfs); + (void) printf("Bootfs: %s\n", entry->me_bootfs); else if (strcasecmp(setting, "bootfs") == 0) { - (void) printf("%s\n", entry->bootfs); + (void) printf("%s\n", entry->me_bootfs); goto done; } @@ -928,7 +971,7 @@ static error_t list_entry(struct menu_lst *menu, char *menu_root, char *opt) { error_t ret = BAM_SUCCESS; - struct menu_entry *entry; + menu_entry_t *entry; char *ptr, *title = NULL; int i, e = -1; @@ -952,11 +995,11 @@ list_entry(struct menu_lst *menu, char *menu_root, char *opt) return (BAM_ERROR); } - STAILQ_FOREACH(entry, menu, next) { + STAILQ_FOREACH(entry, menu, me_next) { if (title != NULL) { - if (strcmp(title, entry->title) == 0) + if (strcmp(title, entry->me_title) == 0) break; - } else if (entry->entry == e) + } else if (entry->me_idx == e) break; } @@ -1133,7 +1176,7 @@ static error_t list_setting(struct menu_lst *menu, char *which, char *setting) { int entry = -1; - struct menu_entry *m; + menu_entry_t *m; be_node_list_t *be_nodes, *be_node = NULL; int ret; @@ -1167,13 +1210,16 @@ list_setting(struct menu_lst *menu, char *which, char *setting) bam_error(_("No BE's found\n")); return (BAM_ERROR); } - STAILQ_FOREACH(m, menu, next) { + STAILQ_FOREACH(m, menu, me_next) { entry++; for (be_node = be_nodes; be_node; - be_node = be_node->be_next_node) - if (strcmp(be_node->be_root_ds, m->bootfs) == 0) + be_node = be_node->be_next_node) { + if (strcmp(be_node->be_root_ds, + m->me_bootfs) == 0) break; - if (be_node->be_active_on_boot == B_TRUE) + } + if (be_node != NULL && + be_node->be_active_on_boot == B_TRUE) break; /* found active node */ } be_free_list(be_nodes); @@ -1182,8 +1228,8 @@ list_setting(struct menu_lst *menu, char *which, char *setting) return (BAM_ERROR); } } else { - STAILQ_FOREACH(m, menu, next) - if (m->entry == entry) + STAILQ_FOREACH(m, menu, me_next) + if (m->me_idx == entry) break; if (m == NULL) { diff --git a/usr/src/cmd/datadm/datadm.c b/usr/src/cmd/datadm/datadm.c index cd10b778de..695affd1c9 100644 --- a/usr/src/cmd/datadm/datadm.c +++ b/usr/src/cmd/datadm/datadm.c @@ -590,7 +590,7 @@ datadm_enqueue_entry(datadm_list_t *list, datadm_entry_t *entry) */ static int datadm_walk_list(datadm_list_t *list, int (*func)(datadm_entry_t *, void *), - void *arg) + void *arg) { datadm_entry_t *entry; int retval = 0; @@ -710,7 +710,7 @@ datadm_sp_entry_match(datadm_sp_entry_t *sp1, datadm_sp_entry_t *sp2) if (sp1->spe_threadsafe != sp2->spe_threadsafe) { return (0); } - if (sp2->spe_default != sp2->spe_default) { + if (sp1->spe_default != sp2->spe_default) { return (0); } if (!datadm_str_match(sp1->spe_libpath, sp2->spe_libpath)) { @@ -921,7 +921,7 @@ datadm_parse_line(char *line_buf, char *tokens[], int *token_count) */ static int datadm_process_sp_entry(datadm_list_t *hca_list, datadm_sp_entry_t *sp_entry, - char *ia_name) + char *ia_name) { datadm_hca_find_t hca_find; datadm_ia_find_t ia_find; @@ -1429,7 +1429,7 @@ out: static int datadm_generate_conf_entry(FILE *outfile, datadm_ia_entry_t *ia_entry, - datadm_sp_entry_t *sp_entry) + datadm_sp_entry_t *sp_entry) { int retval; diff --git a/usr/src/cmd/format/menu_command.c b/usr/src/cmd/format/menu_command.c index d288346d1a..aff9d39ce8 100644 --- a/usr/src/cmd/format/menu_command.c +++ b/usr/src/cmd/format/menu_command.c @@ -2000,7 +2000,7 @@ Unknown disk type in backup label\n"); plist->pinfo_next = parts; } parts->pinfo_name = alloc_string("original"); - for (i = 0; i < NDKMAP; i++) + for (i = 0; i < NDKMAP; i++) { #if defined(_SUNOS_VTOC_8) parts->pinfo_map[i] = label.dkl_map[i]; @@ -2013,6 +2013,7 @@ Unknown disk type in backup label\n"); #else #error No VTOC layout defined. #endif /* defined(_SUNOS_VTOC_8) */ + } parts->vtoc = label.dkl_vtoc; } /* diff --git a/usr/src/cmd/idmap/idmap/namemaps.c b/usr/src/cmd/idmap/idmap/namemaps.c index 1671350a49..bd72a0176d 100644 --- a/usr/src/cmd/idmap/idmap/namemaps.c +++ b/usr/src/cmd/idmap/idmap/namemaps.c @@ -903,9 +903,10 @@ idmap_set_namemap(idmap_nm_handle_t *p, char *winname, char *unixname, if (p->windomain == NULL) { fullname = strdup(winname); - if (fullname == NULL) + if (fullname == NULL) { rc = IDMAP_ERR_MEMORY; goto cleanup; + } } else { fullname = malloc(strlen(winname) + strlen(p->windomain) + 2); diff --git a/usr/src/cmd/logadm/main.c b/usr/src/cmd/logadm/main.c index 219d644de2..93a54a60ed 100644 --- a/usr/src/cmd/logadm/main.c +++ b/usr/src/cmd/logadm/main.c @@ -543,10 +543,11 @@ dologname(struct fn *fnp, struct opts *clopts) char *buf; (void) fprintf(stderr, "dologname: logfiles from cfopts:\n"); fn_list_rewind(logfiles); - while ((nextfnp = fn_list_next(logfiles)) != NULL) + while ((nextfnp = fn_list_next(logfiles)) != NULL) { buf = fn_s(nextfnp); if (buf != NULL) (void) fprintf(stderr, " <%s>\n", buf); + } } if (fn_list_empty(logfiles)) globbedfiles = glob_glob(fnp); @@ -901,10 +902,11 @@ expirefiles(struct fn *fnp, struct opts *opts) buf); } fn_list_rewind(files); - while ((nextfnp = fn_list_next(files)) != NULL) + while ((nextfnp = fn_list_next(files)) != NULL) { buf = fn_s(nextfnp); if (buf != NULL) (void) fprintf(stderr, " <%s>\n", buf); + } } /* see if count causes expiration */ diff --git a/usr/src/cmd/luxadm/adm.c b/usr/src/cmd/luxadm/adm.c index cb2ad51b43..b8c0253b4f 100644 --- a/usr/src/cmd/luxadm/adm.c +++ b/usr/src/cmd/luxadm/adm.c @@ -405,15 +405,15 @@ static const int EOK = 0; /* errno.h type success return code */ static int getaction(char *cmd, struct keyword *matches, int *retval) { -int actlen; + int actlen; /* Idiot checking of pointers */ if (! cmd || ! matches || ! retval || ! (actlen = strlen(cmd))) /* Is there an cmd ? */ return (EFAULT); - /* Keep looping until NULL match string (end of list) */ - while (matches->match) { + /* Keep looping until NULL match string (end of list) */ + while (matches->match) { /* * Precedence: Make sure target is no longer than * current match string @@ -432,7 +432,7 @@ int actlen; } else { matches++; /* Next match string/struct */ } - } /* End of matches loop */ + } /* End of matches loop */ return (EINVAL); } /* End of getaction() */ diff --git a/usr/src/cmd/passmgmt/passmgmt.c b/usr/src/cmd/passmgmt/passmgmt.c index ffb54ff890..d2eef294aa 100644 --- a/usr/src/cmd/passmgmt/passmgmt.c +++ b/usr/src/cmd/passmgmt/passmgmt.c @@ -219,7 +219,8 @@ putuserattrent(userattr_t *user, FILE *f) } static void -assign_attr(userattr_t *user, const char *newkey, char *val) { +assign_attr(userattr_t *user, const char *newkey, char *val) +{ int i; char *key; @@ -247,7 +248,8 @@ assign_attr(userattr_t *user, const char *newkey, char *val) { } static void -unassign_role(userattr_t *user, char *rolelist, char *role) { +unassign_role(userattr_t *user, char *rolelist, char *role) +{ char *roleptr; char *templist; @@ -446,10 +448,10 @@ main(int argc, char **argv) strpbrk(optarg, ":\n")) bad_arg("Invalid argument to option -c"); - optn_mask |= C_MASK; - passwd_st.pw_comment = optarg; - passwd_st.pw_gecos = optarg; - break; + optn_mask |= C_MASK; + passwd_st.pw_comment = optarg; + passwd_st.pw_gecos = optarg; + break; case 'h' : /* The home directory */ diff --git a/usr/src/cmd/regcmp/regcmp.c b/usr/src/cmd/regcmp/regcmp.c index edba830e73..375d1c1f5d 100644 --- a/usr/src/cmd/regcmp/regcmp.c +++ b/usr/src/cmd/regcmp/regcmp.c @@ -27,8 +27,6 @@ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <locale.h> #include <libgen.h> @@ -83,11 +81,13 @@ main(int argc, char **argv) cp = ofile; while (*++bp) if (*bp == '/') *bp = '\0'; - while (*--bp == '\0'); + while (*--bp == '\0') + ; while (*bp != '\0' && bp > *argv) bp--; while (*bp == 0) bp++; - while (*cp++ = *bp++); + while (*cp++ = *bp++) + ; cp--; *cp++ = '.'; if (cflg) *cp++ = 'c'; else *cp++ = 'i'; @@ -104,15 +104,18 @@ main(int argc, char **argv) name = a2; if (!gotflg) while (((c = getc(iobuf)) == '\n') || - (c == ' ')); + (c == ' ')) + ; else gotflg = 0; if (c == EOF) break; *name++ = c; while (((*name++ = c = getc(iobuf)) != ' ') && - (c != EOF) && (c != '\n')); - *--name = '\0'; - while (((c = getc(iobuf)) == ' ') || (c == '\n')); + (c != EOF) && (c != '\n')) + ; + *--name = '\0'; + while (((c = getc(iobuf)) == ' ') || (c == '\n')) + ; if (c != '"') { if (c == EOF) { message = gettext("unexpected eof\n"); @@ -125,7 +128,8 @@ main(int argc, char **argv) message = gettext(" : remainder of line ignored\n"); write(2, message, strlen(message)); - while ((c = getc(iobuf)) != '\n'); + while ((c = getc(iobuf)) != '\n') + ; continue; } keeponl: @@ -167,7 +171,8 @@ main(int argc, char **argv) write(2, message, strlen(message)); exit(1); } - while (((c = getc(iobuf)) == '\n') || (c == ' ')); + while (((c = getc(iobuf)) == '\n') || (c == ' ')) + ; if (c == '"') goto keeponl; else { gotflg++; diff --git a/usr/src/cmd/sendmail/aux/vacation.c b/usr/src/cmd/sendmail/aux/vacation.c index d1f3675985..5a0f93756d 100644 --- a/usr/src/cmd/sendmail/aux/vacation.c +++ b/usr/src/cmd/sendmail/aux/vacation.c @@ -17,12 +17,6 @@ * specifies the terms and conditions for redistribution. */ -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifndef lint -static char SccsId[] = "%W% %E% SMI"; -#endif /* not lint */ - #include <stdio.h> #include <stdarg.h> #include <stdlib.h> @@ -763,9 +757,10 @@ sendmessage(msgf, user, myname) if (f == NULL) { f = fopen("/etc/mail/vacation.def", "r"); - if (f == NULL) + if (f == NULL) { usrerr("No message to send"); exit(EX_OSFILE); + } } if (pipe(pipefd) < 0) { diff --git a/usr/src/cmd/tbl/t7.c b/usr/src/cmd/tbl/t7.c index 337e1f7098..5cdd9fc316 100644 --- a/usr/src/cmd/tbl/t7.c +++ b/usr/src/cmd/tbl/t7.c @@ -12,8 +12,6 @@ * specifies the terms and conditions for redistribution. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* t7.c: control to write table entries */ # include "t..c" # define realsplit ((ct=='a'||ct=='n') && table[ldata][c].rcol) @@ -67,8 +65,8 @@ for(c=0; c<ncol; c++) case 'c': case 'l': case 'r': - if (realsplit? rused[c]: (used[c]+lused[c])) - fprintf(tabout, "\\n(%du ",c+CRIGHT); + if (realsplit? rused[c]: (used[c]+lused[c])) + fprintf(tabout, "\\n(%du ",c+CRIGHT); continue; case 's': if (lspan(lform, c)) diff --git a/usr/src/uts/common/io/arn/arn_rc.c b/usr/src/uts/common/io/arn/arn_rc.c index e6c6170ee7..d70348d074 100644 --- a/usr/src/uts/common/io/arn/arn_rc.c +++ b/usr/src/uts/common/io/arn/arn_rc.c @@ -521,12 +521,12 @@ arn_rc_valid_phyrate(uint32_t phy, uint32_t capflag, int ignore_cw) return (0); if (WLAN_RC_PHY_SGI(phy) && !(capflag & WLAN_RC_SGI_FLAG)) return (0); - if (!ignore_cw && WLAN_RC_PHY_HT(phy)) + if (!ignore_cw && WLAN_RC_PHY_HT(phy)) { if (WLAN_RC_PHY_40(phy) && !(capflag & WLAN_RC_40_FLAG)) return (0); if (!WLAN_RC_PHY_40(phy) && (capflag & WLAN_RC_40_FLAG)) return (0); - + } return (1); } @@ -947,7 +947,7 @@ arn_rc_update_per(struct arn_softc *sc, struct ath_rate_priv *ath_rc_priv, struct ath_tx_info_priv *tx_info_priv, int tx_rate, int xretries, int retries, - uint32_t now_msec) + uint32_t now_msec) { boolean_t state_change = B_FALSE; int count; diff --git a/usr/src/uts/common/io/usb/hcd/xhci/xhci.c b/usr/src/uts/common/io/usb/hcd/xhci/xhci.c index 17d190f3e0..84bd1a13c9 100644 --- a/usr/src/uts/common/io/usb/hcd/xhci/xhci.c +++ b/usr/src/uts/common/io/usb/hcd/xhci/xhci.c @@ -10,7 +10,7 @@ */ /* - * Copyright 2016 Joyent, Inc. + * Copyright (c) 2017, Joyent, Inc. */ /* @@ -1172,12 +1172,19 @@ xhci_read_params(xhci_t *xhcip) uint8_t usb; uint16_t vers; uint32_t struc1, struc2, struc3, cap1, cap2, pgsz; - uint32_t psize, pbit; + uint32_t psize, pbit, capreg; xhci_capability_t *xcap; unsigned long ps; + /* + * While it's tempting to do a 16-bit read at offset 0x2, unfortunately, + * a few emulated systems don't support reading at offset 0x2 for the + * version. Instead we need to read the caplength register and get the + * upper two bytes. + */ + capreg = xhci_get32(xhcip, XHCI_R_CAP, XHCI_CAPLENGTH); + vers = XHCI_VERSION_MASK(capreg); usb = pci_config_get8(xhcip->xhci_cfg_handle, PCI_XHCI_USBREV); - vers = xhci_get16(xhcip, XHCI_R_CAP, XHCI_HCIVERSION); struc1 = xhci_get32(xhcip, XHCI_R_CAP, XHCI_HCSPARAMS1); struc2 = xhci_get32(xhcip, XHCI_R_CAP, XHCI_HCSPARAMS2); struc3 = xhci_get32(xhcip, XHCI_R_CAP, XHCI_HCSPARAMS3); diff --git a/usr/src/uts/common/sys/usb/hcd/xhci/xhcireg.h b/usr/src/uts/common/sys/usb/hcd/xhci/xhcireg.h index 7e23463ea4..f521428852 100644 --- a/usr/src/uts/common/sys/usb/hcd/xhci/xhcireg.h +++ b/usr/src/uts/common/sys/usb/hcd/xhci/xhcireg.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2014 Martin Pieuchot. All rights reserved. * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. - * Copyright 2016 Joyent, Inc. + * Copyright (c) 2017, Joyent, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -58,6 +58,8 @@ extern "C" { #define XHCI_HCIVERSION_0_9 0x0090 /* xHCI version 0.9 */ #define XHCI_HCIVERSION_1_0 0x0100 /* xHCI version 1.0 */ +#define XHCI_VERSION_MASK(x) (((x) >> 16) & 0xffff) + /* * Structural Parameters 1 - xHCI 1.1 / 5.3.3 */ |
