diff options
author | dp <none@none> | 2005-08-15 23:26:22 -0700 |
---|---|---|
committer | dp <none@none> | 2005-08-15 23:26:22 -0700 |
commit | d2117003c7d0588abeea5ed1b925b77f025e2c96 (patch) | |
tree | 77b1ba3f4ac62c017f69ec8df4ca58a568d80892 /usr/src | |
parent | 05a696011d520e93d121a50d3c5e7874d61dac85 (diff) | |
download | illumos-joyent-d2117003c7d0588abeea5ed1b925b77f025e2c96.tar.gz |
6269753 gcc and cmd/sa don't get along
6272664 gcc and cmd/pt_chmod don't get along
6273933 gcc and cmd/tic don't get along
6273957 gcc and cmd/utmpd don't get along
6273960 gcc and cmd/utmp_update don't get along
6307969 gcc and cmd/eeprom don't get along
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/Makefile.lint | 3 | ||||
-rw-r--r-- | usr/src/cmd/eeprom/common/loadlogo.c | 17 | ||||
-rw-r--r-- | usr/src/cmd/eeprom/common/openprom.c | 44 | ||||
-rw-r--r-- | usr/src/cmd/pt_chmod/pt_chmod.c | 27 | ||||
-rw-r--r-- | usr/src/cmd/sa/saga.c | 40 | ||||
-rw-r--r-- | usr/src/cmd/sa/sagb.c | 705 | ||||
-rw-r--r-- | usr/src/cmd/sa/timex.c | 83 | ||||
-rw-r--r-- | usr/src/cmd/tic/tic_error.c | 49 | ||||
-rw-r--r-- | usr/src/cmd/tic/tic_hash.c | 19 | ||||
-rw-r--r-- | usr/src/cmd/tic/tic_main.c | 5 | ||||
-rw-r--r-- | usr/src/cmd/tic/tic_parse.c | 61 | ||||
-rw-r--r-- | usr/src/cmd/tic/tic_scan.c | 19 | ||||
-rw-r--r-- | usr/src/cmd/utmp_update/utmp_update.c | 78 | ||||
-rw-r--r-- | usr/src/cmd/utmpd/utmpd.c | 28 |
14 files changed, 564 insertions, 614 deletions
diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint index 44a648df7c..15a7595956 100644 --- a/usr/src/Makefile.lint +++ b/usr/src/Makefile.lint @@ -210,6 +210,7 @@ COMMON_SUBDIRS = \ cmd/psradm \ cmd/psrinfo \ cmd/psrset \ + cmd/pt_chmod \ cmd/ptools \ cmd/pwck \ cmd/ramdiskadm \ @@ -249,6 +250,8 @@ COMMON_SUBDIRS = \ cmd/truss \ cmd/tty \ cmd/uadmin \ + cmd/utmp_update \ + cmd/utmpd \ cmd/valtools \ cmd/wall \ cmd/wbem \ diff --git a/usr/src/cmd/eeprom/common/loadlogo.c b/usr/src/cmd/eeprom/common/loadlogo.c index 1f64e00479..ebd30f324e 100644 --- a/usr/src/cmd/eeprom/common/loadlogo.c +++ b/usr/src/cmd/eeprom/common/loadlogo.c @@ -23,7 +23,8 @@ /* - * Copyright 1989, Sun Microsystems, Inc. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ #include <stdio.h> @@ -39,10 +40,8 @@ extern int _error(int do_perror, char *fmt, ...); * See <suntool/icon_load.h> for icon file format. */ -loadlogo(name, w, h, logo) - char *name; - int w, h; - char *logo; +int +loadlogo(char *name, int w, int h, char *logo) { FILE *f; int c = 0; @@ -63,12 +62,12 @@ loadlogo(name, w, h, logo) switch (c = getc(f)) { case 'D': if ((c = fscanf(f, "epth=%d", &nval)) == 1 && - nval != 1) + nval != 1) goto badform; break; case 'F': if ((c = fscanf(f, "ormat_version=%d", &nval)) == 1 && - nval != 1) + nval != 1) goto badform; break; case 'H': @@ -92,8 +91,8 @@ loadlogo(name, w, h, logo) eoh: if (c == EOF || - icw != w || ich != h || - bits != 16 && bits != 32) { + icw != w || ich != h || + bits != 16 && bits != 32) { badform: (void) fclose(f); return (_error(NO_PERROR, "header format error in %s", name)); diff --git a/usr/src/cmd/eeprom/common/openprom.c b/usr/src/cmd/eeprom/common/openprom.c index 273f88a62b..36bf325a62 100644 --- a/usr/src/cmd/eeprom/common/openprom.c +++ b/usr/src/cmd/eeprom/common/openprom.c @@ -4,7 +4,7 @@ /* * Open Boot Prom eeprom utility - * Copyright 1989-2002 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -38,8 +38,8 @@ #define MAXPROPSIZE 128 #define MAXNAMESIZE MAXPROPSIZE -#define MAXVALSIZE (8192 - MAXPROPSIZE - sizeof (u_int)) -#define BUFSIZE (MAXPROPSIZE + MAXVALSIZE + sizeof (u_int)) +#define MAXVALSIZE (8192 - MAXPROPSIZE - sizeof (uint_t)) +#define BUFSIZE (MAXPROPSIZE + MAXVALSIZE + sizeof (uint_t)) typedef union { char buf[BUFSIZE]; struct openpromio opp; @@ -64,7 +64,8 @@ static void set_one(char *, char *); static void promclose(); static int promopen(int); -static getpropval(), setpropval(); +static int getpropval(struct openpromio *); +static int setpropval(struct openpromio *); static char *badarchmsg = "Architecture does not support this command.\n"; @@ -132,8 +133,8 @@ main(int argc, char **argv) break; default: exit(_error(NO_PERROR, - "Usage: %s [-v] [-f prom-device] [variable[=value] ...]", - argv[0])); + "Usage: %s [-v] [-f prom-device] " + "[variable[=value] ...]", argv[0])); } setprogname(argv[0]); @@ -161,7 +162,7 @@ main(int argc, char **argv) /* otherwise discard rest of line */ else while ((c = getchar()) != '\n' && - c != EOF) + c != EOF) /* nothing */; do_var(line); @@ -185,7 +186,7 @@ main(int argc, char **argv) static void do_var(char *var) { - register char *val; + char *val; val = strchr(var, '='); @@ -220,7 +221,7 @@ static void dump_all() { Oppbuf oppbuf; - register struct openpromio *opp = &(oppbuf.opp); + struct openpromio *opp = &(oppbuf.opp); if (promopen(O_RDONLY)) { (void) fprintf(stderr, badarchmsg); @@ -253,14 +254,14 @@ static void print_one(char *var) { Oppbuf oppbuf; - register struct openpromio *opp = &(oppbuf.opp); + struct openpromio *opp = &(oppbuf.opp); (void) strlcpy(opp->oprom_array, var, MAXNAMESIZE); if (getpropval(opp) || opp->oprom_size <= 0) (void) printf("%s: data not available.\n", var); else { /* If necessary, massage the output */ - register struct opvar *v; + struct opvar *v; for (v = opvar; v->name; v++) if (strcmp(var, v->name) == 0) @@ -280,8 +281,8 @@ static void set_one(char *var, char *val) { Oppbuf oppbuf; - register struct openpromio *opp = &(oppbuf.opp); - register struct opvar *v; + struct openpromio *opp = &(oppbuf.opp); + struct opvar *v; if (verbose) { (void) printf("old:"); @@ -346,8 +347,8 @@ promclose() exit(_error(PERROR, "close error on %s", promdev)); } -static -getpropval(register struct openpromio *opp) +static int +getpropval(struct openpromio *opp) { opp->oprom_size = MAXVALSIZE; @@ -357,8 +358,8 @@ getpropval(register struct openpromio *opp) return (0); } -static -setpropval(register struct openpromio *opp) +static int +setpropval(struct openpromio *opp) { /* Caller must set opp->oprom_size */ @@ -398,7 +399,7 @@ i_secure(char *var, char *val, struct openpromio *opp) { int secure; Oppbuf oppbuf; - register struct openpromio *opp2 = &(oppbuf.opp); + struct openpromio *opp2 = &(oppbuf.opp); char pwbuf[PW_SIZE + 2]; int varlen1, varlen2; @@ -428,7 +429,7 @@ i_secure(char *var, char *val, struct openpromio *opp) /* no password yet, get one */ if (get_password(pwbuf, PW_SIZE)) { (void) strcpy(opp2->oprom_array + varlen2, - pwbuf); + pwbuf); opp2->oprom_size = varlen2 + strlen(pwbuf); /* set password first */ if (setpropval(opp2) || setpropval(opp)) @@ -467,7 +468,7 @@ i_passwd(char *var, char *val, struct openpromio *opp) { int secure; Oppbuf oppbuf; - register struct openpromio *opp2 = &(oppbuf.opp); + struct openpromio *opp2 = &(oppbuf.opp); char pwbuf[PW_SIZE + 2]; int varlen; @@ -550,8 +551,7 @@ tryagain: ok = 1; if (!ok && insist < 2) { (void) printf("Please use %s.\n", flags == 1 ? - "at least one non-numeric character" : - "a longer password"); + "at least one non-numeric character" : "a longer password"); insist++; goto tryagain; } diff --git a/usr/src/cmd/pt_chmod/pt_chmod.c b/usr/src/cmd/pt_chmod/pt_chmod.c index cd98c2c8cf..4d09efd5a0 100644 --- a/usr/src/cmd/pt_chmod/pt_chmod.c +++ b/usr/src/cmd/pt_chmod/pt_chmod.c @@ -21,13 +21,17 @@ */ /* * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T - * Copyright (c) 2000, 2001 by Sun Microsystems, Inc. - * All rights reserved. + * + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ +#pragma ident "%Z%%M% %I% %E% SMI" +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include <grp.h> #include <stdlib.h> #include <stropts.h> @@ -40,6 +44,7 @@ * 1) change the owner and mode of the pseudo terminal slave device. * 2) (re)create nodes and devlinks for pseduo terminal slave device. */ +int main(int argc, char **argv) { int fd; @@ -50,7 +55,7 @@ main(int argc, char **argv) struct group *gr_name_ptr; if (argc > 2) - exit(1); + return (1); if ((gr_name_ptr = getgrnam(DEFAULT_TTY_GROUP)) != NULL) gid = gr_name_ptr->gr_gid; @@ -61,10 +66,10 @@ main(int argc, char **argv) if (argc == 1) { pp = di_devlink_init("pts", DI_MAKE_LINK); if (pp != NULL) { - di_devlink_fini(&pp); - exit(0); + (void) di_devlink_fini(&pp); + return (0); } - exit(1); + return (1); } fd = atoi(argv[1]); @@ -72,7 +77,7 @@ main(int argc, char **argv) tty = ptsname(fd); if (tty == NULL) - exit(1); + return (1); /* * Detach all STREAMs. @@ -106,10 +111,10 @@ main(int argc, char **argv) } if (chown(tty, getuid(), gid)) - exit(1); + return (1); if (chmod(tty, 00620)) - exit(1); + return (1); - exit(0); + return (0); } diff --git a/usr/src/cmd/sa/saga.c b/usr/src/cmd/sa/saga.c index 02c6a2a426..1e62238fa0 100644 --- a/usr/src/cmd/sa/saga.c +++ b/usr/src/cmd/sa/saga.c @@ -28,27 +28,28 @@ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8.2.4 */ - -/* saga.c 1.8.2.4 of 6/2/89 */ +#pragma ident "%Z%%M% %I% %E% SMI" #include "saghdr.h" #include <limits.h> #include <strings.h> #include <stdio.h> +#include <stdlib.h> #include <unistd.h> char fld[NFLD][10]; char cmd[300]; long sardoff; -long ftell(); FILE *sard; -FILE *fopen(); +static void printar(struct array *ptr); +static void parse(struct p *p); +static void plot(struct p[], int, char *, char *, char *, char *); +static void scale(struct p[], int, char *, char *, char *, char *); + +int main(int argc, char *argv[]) { - extern char *optarg; - extern int optind; extern char cmd[]; extern char fld[NFLD][FLDCH]; char sarg[10]; @@ -246,8 +247,8 @@ main(int argc, char *argv[]) exit(0); } -printar(ptr) - struct array *ptr; +static void +printar(struct array *ptr) { int i; @@ -268,8 +269,8 @@ printar(ptr) * found in p->spec, placing field names in p->c[j].name, * operators in p->c[j].op, and ranges in p->mn, p->mx, p->min, and p->max */ -parse(p) - struct p *p; +static void +parse(struct p *p) { int n, j; char f[11][18]; @@ -310,11 +311,9 @@ parse(p) } } -plot(p, nplot, xlab_s, xlab_e, title, Targ) - struct p p[]; - int nplot; - char *xlab_s, *xlab_e, *title; - char *Targ; +static void +plot(struct p p[], int nplot, char *xlab_s, char *xlab_e, char *title, + char *Targ) { extern char cmd[]; FILE *pipe, *popen(); @@ -449,6 +448,7 @@ plot(p, nplot, xlab_s, xlab_e, title, Targ) system(cmd); } +int reduce(struct p *pr) { int i, j; @@ -499,11 +499,9 @@ reduce(struct p *pr) return (0); } -scale(p, nplot, sarg, earg, xlab_s, xlab_e) - struct p p[]; - int nplot; - char *sarg, *earg; - char *xlab_s, *xlab_e; +static void +scale(struct p p[], int nplot, char *sarg, char *earg, char *xlab_s, + char *xlab_e) { /* * Scans each data set to find and label those that contain diff --git a/usr/src/cmd/sa/sagb.c b/usr/src/cmd/sa/sagb.c index f696aab329..5c8a591b02 100644 --- a/usr/src/cmd/sa/sagb.c +++ b/usr/src/cmd/sa/sagb.c @@ -19,323 +19,308 @@ * * CDDL HEADER END */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */ -/* sagb.c 1.5 of 5/13/85 */ -#include "saghdr.h" +#pragma ident "%Z%%M% %I% %E% SMI" -combine(p, pn) -struct p *p; -int pn; +#include "saghdr.h" +#include <strings.h> +#include <stdlib.h> +void +combine(struct p *p, int pn) { -int a, b, c; -int i; -int qi = 0; -float vala, valb; -struct array *ara, *arb, *arc; -struct array *popar(); -char *strcpy(); - -ara = p->c[pn].dptr; -arb = p->c[pn+1].dptr; -arc = popar(); -if(DEBUG){fprintf(stderr, "combine p->c[%d].name:%s & p->c[%d].name:%s\n", - pn, p->c[pn].name, pn+1, p->c[pn+1].name); - fprintf(stderr, " alias ara->hname:%s arb->hname:%s\n", - ara->hname, arb->hname); + int a, b, c; + int i; + int qi = 0; + float vala, valb; + struct array *ara, *arb, *arc; + struct array *popar(); + + ara = p->c[pn].dptr; + arb = p->c[pn+1].dptr; + arc = popar(); + if (DEBUG) { + fprintf(stderr, + "combine p->c[%d].name:%s & p->c[%d].name:%s\n", + pn, p->c[pn].name, pn+1, p->c[pn+1].name); + fprintf(stderr, " alias ara->hname:%s arb->hname:%s\n", + ara->hname, arb->hname); } -for(a=b=c=0; a<NPTS && b<NPTS && c<NPTS; ) - { - if((ara->ent[a].hr == 0) || (arb->ent[b].hr == 0)) - { /* End of file */ - arc->ent[c].hr = 0; - break; + for (a = b = c = 0; a < NPTS && b < NPTS && c < NPTS; ) { + if ((ara->ent[a].hr == 0) || (arb->ent[b].hr == 0)) { + /* End of file */ + arc->ent[c].hr = 0; + break; + } + + if ((ara->ent[0].hr < 0) || (arb->ent[0].hr < 0)) { + /* One or both is a constant */ + if ((ara->ent[a].val <= -1000) || + (arb->ent[b].val <= -1000)) + arc->ent[c].val = -1000; + else + switch (p->c[pn].op) { + case '+': + arc->ent[c].val = + ara->ent[a].val + arb->ent[b].val; + break; + case '-': + arc->ent[c].val = + ara->ent[a].val - arb->ent[b].val; + break; + case '*': + arc->ent[c].val = + ara->ent[a].val * arb->ent[b].val; + break; + case '/': + if (arb->ent[b].val != 0) + arc->ent[c].val = + ara->ent[a].val / + arb->ent[b].val; + else + arc->ent[c].val = 0; + break; + default: + break; + } + + if (ara->ent[0].hr >= 0) { + /* a is variable */ + strcpy(arc->ent[c].tm, ara->ent[a].tm); + strcpy(arc->ent[c].qfld, ara->ent[a].qfld); + arc->ent[c].hr = ara->ent[a].hr; + a++; + } else if (arb->ent[0].hr >= 0) { + /* b is variable */ + strcpy(arc->ent[c].tm, arb->ent[b].tm); + strcpy(arc->ent[c].qfld, arb->ent[b].qfld); + arc->ent[c].hr = arb->ent[b].hr; + b++; + } else { + /* Both are constant */ + strcpy(arc->ent[c].tm, ara->ent[a].tm); + strcpy(arc->ent[c].qfld, ara->ent[a].qfld); + arc->ent[c].hr = ara->ent[a].hr; + a++; + b++; + } + c++; + continue; } - if((ara->ent[0].hr < 0) || (arb->ent[0].hr < 0)) - { /* One or both is a constant */ - if((ara->ent[a].val <= -1000) || (arb->ent[b].val <= -1000)) + if (ara->ent[a].hr < arb->ent[b].hr) { + /* b missing */ + arc->ent[c].hr = ara->ent[a].hr; + strcpy(arc->ent[c].tm, ara->ent[a].tm); + strcpy(arc->ent[c].qfld, ara->ent[a].qfld); + vala = ara->ent[a].val; + valb = 0.; + a++; + } else if (ara->ent[a].hr > arb->ent[b].hr) { + /* a missing */ + arc->ent[c].hr = arb->ent[b].hr; + strcpy(arc->ent[c].tm, arb->ent[b].tm); + strcpy(arc->ent[c].qfld, arb->ent[b].qfld); + valb = arb->ent[b].val; + vala = 0.; + b++; + } else { + /* a & b hrs equal */ + arc->ent[c].hr = ara->ent[a].hr; + strcpy(arc->ent[c].tm, ara->ent[a].tm); + vala = ara->ent[a].val; + valb = arb->ent[b].val; + /* + * Test which index can be incremented without + * incurring a change in ..hr + */ + if ((ara->ent[a+1].hr == ara->ent[a].hr) && + (arb->ent[b+1].hr != arb->ent[b].hr)) { + /* a free, b constrained */ + strcpy(arc->ent[c].qfld, ara->ent[a].qfld); + qi = 0; + a++; + } else if ((ara->ent[a+1].hr != ara->ent[a].hr) && + (arb->ent[b+1].hr == arb->ent[b].hr)) { + /* a constrained, b free */ + strcpy(arc->ent[c].qfld, arb->ent[b].qfld); + qi = 1; + b++; + } else { + /* Both free or both constrained */ + if (qi == 1) + strcpy(arc->ent[c].qfld, + arb->ent[b].qfld); + else + strcpy(arc->ent[c].qfld, + ara->ent[a].qfld); + a++; + b++; + } + } + if ((vala <= -1000) || (valb <= -1000)) arc->ent[c].val = -1000; else - switch (p->c[pn].op) - { + switch (p->c[pn].op) { case '+': - arc->ent[c].val = ara->ent[a].val + arb->ent[b].val; + arc->ent[c].val = vala + valb; break; case '-': - arc->ent[c].val = ara->ent[a].val - arb->ent[b].val; + arc->ent[c].val = vala - valb; break; case '*': - arc->ent[c].val = ara->ent[a].val * arb->ent[b].val; + arc->ent[c].val = vala * valb; break; case '/': - if(arb->ent[b].val != 0) - arc->ent[c].val = ara->ent[a].val / arb->ent[b].val; + if (valb != 0) + arc->ent[c].val = vala / valb; else arc->ent[c].val = 0; break; default: break; } - if(ara->ent[0].hr >= 0) - { /* a is variable */ - strcpy(arc->ent[c].tm, ara->ent[a].tm); - strcpy(arc->ent[c].qfld, ara->ent[a].qfld); - arc->ent[c].hr = ara->ent[a].hr; - a++; - } - else if(arb->ent[0].hr >= 0) - { /* b is variable */ - strcpy(arc->ent[c].tm, arb->ent[b].tm); - strcpy(arc->ent[c].qfld, arb->ent[b].qfld); - arc->ent[c].hr = arb->ent[b].hr; - b++; - } - else - { /* Both are constant */ - strcpy(arc->ent[c].tm, ara->ent[a].tm); - strcpy(arc->ent[c].qfld, ara->ent[a].qfld); - arc->ent[c].hr = ara->ent[a].hr; - a++; - b++; - } c++; - continue; - } - - if(ara->ent[a].hr < arb->ent[b].hr) - { /* b missing */ - arc->ent[c].hr = ara->ent[a].hr; - strcpy(arc->ent[c].tm, ara->ent[a].tm); - strcpy(arc->ent[c].qfld, ara->ent[a].qfld); - vala = ara->ent[a].val; - valb = 0.; - a++; - } - else if(ara->ent[a].hr > arb->ent[b].hr) - { /* a missing */ - arc->ent[c].hr = arb->ent[b].hr; - strcpy(arc->ent[c].tm, arb->ent[b].tm); - strcpy(arc->ent[c].qfld, arb->ent[b].qfld); - valb = arb->ent[b].val; - vala = 0.; - b++; - } - else - { /* a & b hrs equal */ - arc->ent[c].hr = ara->ent[a].hr; - strcpy(arc->ent[c].tm, ara->ent[a].tm); - vala = ara->ent[a].val; - valb = arb->ent[b].val; -/* -** Test which index can be incremented without -** incurring a change in ..hr -*/ - if((ara->ent[a+1].hr == ara->ent[a].hr) - && (arb->ent[b+1].hr != arb->ent[b].hr)) - { /* a free, b constrained */ - strcpy(arc->ent[c].qfld, ara->ent[a].qfld); - qi = 0; - a++; - } - else if((ara->ent[a+1].hr != ara->ent[a].hr) - && (arb->ent[b+1].hr == arb->ent[b].hr)) - { /* a constrained, b free */ - strcpy(arc->ent[c].qfld, arb->ent[b].qfld); - qi = 1; - b++; - } - else - { /* Both free or both constrained */ - if(qi == 1) - strcpy(arc->ent[c].qfld, arb->ent[b].qfld); - else - strcpy(arc->ent[c].qfld, ara->ent[a].qfld); - a++; - b++; - } - } - if((vala <= -1000) || (valb <= -1000)) - arc->ent[c].val = -1000; - else - switch (p->c[pn].op) - { - case '+': - arc->ent[c].val = vala + valb; - break; - case '-': - arc->ent[c].val = vala - valb; - break; - case '*': - arc->ent[c].val = vala * valb; - break; - case '/': - if(valb != 0) - arc->ent[c].val = vala / valb; - else - arc->ent[c].val = 0; - break; - default: - break; - } - c++; } -sprintf(arc->hname, "%s %c %s", ara->hname, p->c[pn].op, arb->hname); -if(DEBUG){printar(ara); - printar(arb); - printar(arc); + sprintf(arc->hname, "%s %c %s", ara->hname, p->c[pn].op, arb->hname); + if (DEBUG) { + printar(ara); + printar(arb); + printar(arc); } -pushar(ara); -pushar(arb); -p->c[pn].op = p->c[pn+1].op; -p->c[pn].dptr = arc; -for(i=pn+1; i<4; i++) - { - strcpy(p->c[i].name, p->c[i+1].name); - p->c[i].op = p->c[i+1].op; - p->c[i].dptr = p->c[i+1].dptr; + pushar(ara); + pushar(arb); + p->c[pn].op = p->c[pn+1].op; + p->c[pn].dptr = arc; + for (i = pn + 1; i < 4; i++) { + strcpy(p->c[i].name, p->c[i+1].name); + p->c[i].op = p->c[i+1].op; + p->c[i].dptr = p->c[i+1].dptr; } } -/************************************************/ - -getdata(name, array) -char *name; -struct array *array; /* -** Extracts data from sarc[] array and puts into -** array entries. Hunts for name string among column -** headers in sarc, and copies following data items -** from corresponding field up to next "Average" line. -** Special treatment when name string contains an integer -** or "time". -*/ - + * Extracts data from sarc[] array and puts into array entries. Hunts for name + * string among column headers in sarc, and copies following data items from + * corresponding field up to next "Average" line. Special treatment when name + * string contains an integer or "time". + */ +int +getdata(char *name, struct array *array) { -extern char fld[NFLD][FLDCH]; -extern FILE *sard; -extern long sardoff; -int fnum; -char nm[18], ql[8]; -int nparts; -int i, j; -int timeflg; -int hr, min, sec; -int nmloc; -double atof(); -float hour; -char *strcpy(); -char *strtok(); -char *tok; - -if(DEBUG) fprintf(stderr, "getdata-> name:%s\n", name); -if(sscanf(name,"%f", &array->ent[0].val) == 1) /* name contains a constant */ - { /* no sar data is required */ - strcpy(array->ent[0].tm, "***"); - strcpy(array->hname, name); - array->ent[0].hr = -1; - array->ent[0].qfld[0] = '\0'; - array->ent[1].hr = 0; - return(0); + extern char fld[NFLD][FLDCH]; + extern FILE *sard; + extern long sardoff; + int fnum; + char nm[18], ql[8]; + int nparts; + int i, j; + int timeflg; + int hr, min, sec; + int nmloc; + float hour; + char *tok; + + if (DEBUG) + fprintf(stderr, "getdata-> name:%s\n", name); + + /* name contains a constant */ + if (sscanf(name, "%f", &array->ent[0].val) == 1) { + /* no sar data is required */ + strcpy(array->ent[0].tm, "***"); + strcpy(array->hname, name); + array->ent[0].hr = -1; + array->ent[0].qfld[0] = '\0'; + array->ent[1].hr = 0; + return (0); } -if(strmatch("time", name) >= 0) /* Pick up time values from */ - { /* 1st sar group - %usr */ - if(DEBUG) fprintf(stderr, "name matches time\n"); - strcpy(nm, "%usr"); - strcpy(ql, ""); - nparts = 1; - timeflg = 1; - } -else - { - nparts = 0; - timeflg = 0; - if((tok = strtok(name, "[]")) != NULL) - { + if (strmatch("time", name) >= 0) { + /* Pick up time values from 1st sar group - %usr */ + if (DEBUG) + fprintf(stderr, "name matches time\n"); + strcpy(nm, "%usr"); + strcpy(ql, ""); nparts = 1; - strcpy(nm, tok); + timeflg = 1; + } else { + nparts = 0; + timeflg = 0; + if ((tok = strtok(name, "[]")) != NULL) { + nparts = 1; + strcpy(nm, tok); } - if((tok = strtok(0, "[]")) != NULL) - { - nparts++; - strcpy(ql, tok); - } - else - strcpy(ql, ""); + if ((tok = strtok(0, "[]")) != NULL) { + nparts++; + strcpy(ql, tok); + } else + strcpy(ql, ""); } -/* fprintf(stderr, "nparts:%d nm:%s ql:%s\n", nparts, nm, ql); -*/ -fseek(sard, sardoff, 0); /* seek to line 2 of sard */ -while((fnum = getfld()) != EOF) - { - for(i=0; i<fnum; i++) - if(strmatch(nm, fld[i]) >= 0) - { - if(timeflg == 1) - { - nmloc = 0; - strcpy(array->hname, "time"); - } - else - { - nmloc = i ; - if(nparts < 2) - strcpy(array->hname, fld[i]); - else - sprintf(array->hname, "%s[%s]", - fld[i], ql); + /* fprintf(stderr, "nparts:%d nm:%s ql:%s\n", nparts, nm, ql); */ + + fseek(sard, sardoff, 0); /* seek to line 2 of sard */ + while ((fnum = getfld()) != EOF) { + for (i = 0; i < fnum; i++) + if (strmatch(nm, fld[i]) >= 0) { + if (timeflg == 1) { + nmloc = 0; + strcpy(array->hname, "time"); + } else { + nmloc = i; + if (nparts < 2) + strcpy(array->hname, fld[i]); + else + sprintf(array->hname, "%s[%s]", + fld[i], ql); } - goto readin; + goto readin; } } -fprintf(stderr, "\"%s\" data not found\n", nm); -return(-1); + fprintf(stderr, "\"%s\" data not found\n", nm); + return (-1); readin: - for(i=0; i<NPTS; ) - { - if(((fnum = getfld()) == EOF) - || (strmatch(":", fld[0]) < 0)) - { + for (i = 0; i < NPTS; ) { + if (((fnum = getfld()) == EOF) || (strmatch(":", fld[0]) < 0)) { array->ent[i].hr = 0; - return(0); - } - if(DEBUG>1) { - for (j=0; j<fnum; j++) + return (0); + } + if (DEBUG > 1) { + for (j = 0; j < fnum; j++) fprintf(stderr, " %s", fld[j]); fputc('\n', stderr); - } + } sscanf(fld[0], "%d:%d:%d", &hr, &min, &sec); hour = (float)hr + (float)min/60 + (float)sec/3600; - if(timeflg == 1) - { + if (timeflg == 1) { strcpy(array->ent[i].tm, fld[0]); array->ent[i].hr = hour; array->ent[i].val = hour; strcpy(array->ent[i].qfld, ""); i++; continue; - } - if(strmatch("unix", fld[1]) >= 0) - { + } + if (strmatch("unix", fld[1]) >= 0) { strcpy(array->ent[i].tm, fld[0]); array->ent[i].hr = hour; array->ent[i].val = -1000.; strcpy(array->ent[i].qfld, ""); i++; continue; - } - if((nparts > 1) && (strmatch(ql, fld[1]) < 0)) + } + if ((nparts > 1) && (strmatch(ql, fld[1]) < 0)) continue; strcpy(array->ent[i].tm, fld[0]); @@ -343,56 +328,55 @@ readin: array->ent[i].val = atof(fld[nmloc]); strcpy(array->ent[i].qfld, fld[1]); - if(DEBUG>1) + if (DEBUG > 1) fprintf(stderr, " .val:%.3f\n", array->ent[i].val); i++; - } -return(0); + } + return (0); } -/************************************************/ - -getfld() /* -** Scans characters pointed to by cp; -** puts non-blank strings into fld[NFLD][FLDCH] -** up to first newline or EOF. -** Returns number of fld's filled (or EOF), -** with cp updated to next readable char. -*/ + * Scans characters pointed to by cp; puts non-blank strings into + * fld[NFLD][FLDCH] up to first newline or EOF. + * + * Returns number of fld's filled (or EOF), with cp updated to next readable + * char. + */ +int +getfld() { -extern char fld[NFLD][FLDCH]; -extern FILE *sard; -int fnum=0, i=0; -int c; - -while((c = getc(sard)) != EOF) - switch((char)c){ - case ' ': - fld[fnum][i] = '\0'; - i = 0; - if(++fnum >= 9) return(fnum); - break; - case '\n': - fld[fnum][i] = '\0'; - return(++fnum); - break; - default: - fld[fnum][i++] = c; - break; - } + extern char fld[NFLD][FLDCH]; + extern FILE *sard; + int fnum = 0, i = 0; + int c; + + while ((c = getc(sard)) != EOF) + switch ((char)c) { + case ' ': + fld[fnum][i] = '\0'; + i = 0; + if (++fnum >= 9) + return (fnum); + break; + case '\n': + fld[fnum][i] = '\0'; + return (++fnum); + break; + default: + fld[fnum][i++] = c; + break; + } -fld[fnum][i] = '\0'; -if((i == 0) && (fnum == 0)) return(EOF); -else return(++fnum); + fld[fnum][i] = '\0'; + if ((i == 0) && (fnum == 0)) + return (EOF); + else + return (++fnum); } -/************************************************/ - - static struct array stack[10]; static struct array *sp[] = { &stack[0], @@ -409,105 +393,98 @@ static int spn = 10; -struct array *popar() +struct array * +popar() { -if(spn > 0) - return(sp[--spn]); -else + if (spn > 0) + return (sp[--spn]); + else { - fprintf(stderr, "Stack empty\n"); - exit(); + fprintf(stderr, "Stack empty\n"); + exit(1); } } -pushar(par) -struct array *par; - +int +pushar(struct array *par) { -if(spn < 10) - { - sp[spn++] = par; - return(1); - } -else - { - fprintf(stderr, "Stack full\n"); - return(0); + if (spn < 10) { + sp[spn++] = par; + return (1); + } else { + fprintf(stderr, "Stack full\n"); + return (0); } } -/************************************************/ - -stribl(s) -char *s; /* -** Strips leading and trailing blanks from string -** by moving string pointer to first non-blank character, -** and replacing trailing blanks with '\0'. -** Returns number of remaining characters. -*/ - + * Strips leading and trailing blanks from string + * by moving string pointer to first non-blank character, + * and replacing trailing blanks with '\0'. + * Returns number of remaining characters. + */ +int +stribl(char *s) { -char *a, *b; - -a = b = s; -while (*b == ' ') b++; -while ((*a++ = *b++) != '\0'); -a--; -while (a-- > s) - if (*a != ' ') break; - else *a = '\0'; -return (int)(a-s+1); -} + char *a, *b; - -/************************************************/ + a = b = s; + while (*b == ' ') + b++; + while ((*a++ = *b++) != '\0') + ; + a--; + while (a-- > s) + if (*a != ' ') + break; + else + *a = '\0'; + return (int)(a-s+1); +} -int strmatch (pat, targ) -char *pat, *targ; /* -** strmatch looks for an occurrence of string pat -** inside string targ. It returns the number of -** the first starting character position (zero is valid), -** or -1 for no match. -*/ - + * strmatch looks for an occurrence of string pat + * inside string targ. It returns the number of + * the first starting character position (zero is valid), + * or -1 for no match. + */ +int +strmatch(char *pat, char *targ) { -int i, c, ifirst; + int i, c, ifirst; -for (ifirst=0; ; ifirst++) - { - i=0; - do - { - if(pat[i] == '\0') - return(ifirst); - if (targ[ifirst + i] == '\0') - return(-1); - c=i++; - } - while (pat[c] == targ[ifirst + c]); + for (ifirst = 0; ; ifirst++) { + i = 0; + do { + if (pat[i] == '\0') + return (ifirst); + if (targ[ifirst + i] == '\0') + return (-1); + c = i++; + } while (pat[c] == targ[ifirst + c]); } } -/************************************************/ - -float yrange(ff) -float ff; +float +yrange(float ff) { -static float ylimit[] = {1.0, 1.5, 2.5, 5.0, 10.0}; -float div = 1; -int i = 0; -if (ff <= 0.) return(0); -while (ff/div > 10.) div *= 10.; -while (ff/div < 1.) div /= 10.; -while ((ff/div) > ylimit[i]) i++; -return (ylimit[i] * div); + static float ylimit[] = {1.0, 1.5, 2.5, 5.0, 10.0}; + float div = 1; + int i = 0; + if (ff <= 0.) + return (0); + while (ff/div > 10.) + div *= 10.; + while (ff/div < 1.) + div /= 10.; + while ((ff/div) > ylimit[i]) + i++; + return (ylimit[i] * div); } diff --git a/usr/src/cmd/sa/timex.c b/usr/src/cmd/sa/timex.c index 65b345b88b..8bc07f062f 100644 --- a/usr/src/cmd/sa/timex.c +++ b/usr/src/cmd/sa/timex.c @@ -19,31 +19,29 @@ * * CDDL HEADER END */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.19 */ -/* timex.c 1.19 of 7/21/89 */ +#pragma ident "%Z%%M% %I% %E% SMI" + #include <sys/types.h> #include <sys/times.h> #include <sys/param.h> +#include <sys/wait.h> +#include <unistd.h> #include <stdio.h> +#include <stdlib.h> #include <signal.h> +#include <strings.h> #include <time.h> #include <errno.h> #include <pwd.h> -long atol(); -extern time_t time(); -int isatty(); -char *ttyname(); -char *strcat(); -char *strncpy(); -struct passwd *getpwuid(); - -extern int errno; -extern char *sys_errlist[]; char fname[20]; /* @@ -51,9 +49,12 @@ char fname[20]; */ char quant[] = { 10, 10, 10, 6, 10, 6, 10, 10, 10 }; -main(argc, argv) -int argc; -char **argv; +void printt(char *, time_t); +void hmstime(char[]); +void diag(char *); + +int +main(int argc, char **argv) { struct tms buffer, obuffer; int status; @@ -66,7 +67,7 @@ char **argv; extern int optind; int pflg = 0, sflg = 0, oflg = 0; char aopt[25]; - FILE *popen(), *pipin; + FILE *pipin; char ttyid[12], line[150]; char eol; char fld[20][12]; @@ -105,9 +106,9 @@ char **argv; oflg = 0; pflg = 0; fprintf(stderr, - "Information from -p and -o options not available\n"); + "Information from -p and -o options not available\n"); fprintf(stderr, - " because process accounting is not operational.\n"); + " because process accounting is not operational.\n"); } if (sflg) { @@ -121,12 +122,13 @@ char **argv; if (p == 0) { setgid(getgid()); execvp(*(argv+optind), (argv+optind)); - fprintf(stderr, "%s: %s\n", *(argv+optind), sys_errlist[errno]); + fprintf(stderr, "%s: %s\n", *(argv+optind), strerror(errno)); exit(1); } signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); - while (wait(&status) != p); + while (wait(&status) != p) + ; if ((status&0377) != 0) fprintf(stderr, "Command terminated abnormally.\n"); signal(SIGINT, SIG_DFL); @@ -145,18 +147,19 @@ char **argv; if (isatty(0)) sprintf(ttyid, "-l %s", ttyname(0)+5); sprintf(cmd, "acctcom -S %s -E %s -u %s %s -i %s", - stime, etime, getpwuid(getuid())->pw_name, ttyid, aopt); + stime, etime, getpwuid(getuid())->pw_name, ttyid, aopt); pipin = popen(cmd, "r"); while (fscanf(pipin, "%[^\n]%1c", line, &eol) > 1) { if (pflg) fprintf(stderr, "%s\n", line); if (oflg) { nfld = sscanf(line, - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", - fld[0], fld[1], fld[2], fld[3], fld[4], - fld[5], fld[6], fld[7], fld[8], fld[9], - fld[10], fld[11], fld[12], fld[13], fld[14], - fld[15], fld[16], fld[17], fld[18], fld[19]); + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + fld[0], fld[1], fld[2], fld[3], fld[4], + fld[5], fld[6], fld[7], fld[8], fld[9], + fld[10], fld[11], fld[12], fld[13], fld[14], + fld[15], fld[16], fld[17], fld[18], + fld[19]); if (++iline == 3) for (i = 0; i < nfld; i++) { if (strcmp(fld[i], "CHARS") @@ -177,16 +180,15 @@ char **argv; if (oflg) if (iline > 4) fprintf(stderr, - "\nCHARS TRNSFD = %ld\nBLOCKS READ = %ld\n", - chars, bloks); + "\nCHARS TRNSFD = %ld\n" + "BLOCKS READ = %ld\n", chars, bloks); else fprintf(stderr, - "\nNo process records found!\n"); + "\nNo process records found!\n"); } if (sflg) { - sprintf(cmd, - "/usr/bin/sar -ubdycwaqvmpgrk -f %s 1>&2", fname); + sprintf(cmd, "/usr/bin/sar -ubdycwaqvmpgrk -f %s 1>&2", fname); system(cmd); unlink(fname); } @@ -197,12 +199,11 @@ char *pad = "000 "; char *sep = "\0\0.\0:\0:\0\0"; char *nsep = "\0\0.\0 \0 \0\0"; -printt(s, a) -char *s; -time_t a; +void +printt(char *s, time_t a) { char digit[9]; - register i; + int i; char c; int nonzero; @@ -226,11 +227,11 @@ time_t a; } /* -** hmstime() sets current time in hh:mm:ss string format in stime; -*/ + * hmstime() sets current time in hh:mm:ss string format in stime; + */ -hmstime(stime) -char stime[]; +void +hmstime(char stime[]) { char *ltime; time_t tme; @@ -241,8 +242,8 @@ char stime[]; stime[8] = '\0'; } -diag(s) -char *s; +void +diag(char *s) { fprintf(stderr, "%s\n", s); unlink(fname); diff --git a/usr/src/cmd/tic/tic_error.c b/usr/src/cmd/tic/tic_error.c index 13bf098848..e9aeeb3f9b 100644 --- a/usr/src/cmd/tic/tic_error.c +++ b/usr/src/cmd/tic/tic_error.c @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -87,38 +87,22 @@ */ #include <unistd.h> +#include <stdarg.h> +#include <stdlib.h> #include "compiler.h" -#ifdef __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif extern char *string_table; extern short term_names; extern char *progname; /* VARARGS1 */ -#ifdef __STDC__ void warning(char *fmt, ...) -#else -warning(va_alist) -va_dcl -#endif { -#ifndef __STDC__ - register char *fmt; -#endif va_list args; -#ifdef __STDC__ va_start(args, fmt); -#else - va_start(args); - fmt = va_arg(args, char *); -#endif fprintf(stderr, "%s: Warning: near line %d: ", progname, curr_line); if (string_table != NULL) { fprintf(stderr, "terminal '%s', ", string_table+term_names); @@ -130,24 +114,12 @@ va_dcl /* VARARGS1 */ -#ifdef __STDC__ +void err_abort(char *fmt, ...) -#else -err_abort(va_alist) -va_dcl -#endif { -#ifndef __STDC__ - register char *fmt; -#endif va_list args; -#ifdef __STDC__ va_start(args, fmt); -#else - va_start(args); - fmt = va_arg(args, char *); -#endif fprintf(stderr, "%s: Line %d: ", progname, curr_line); if (string_table != NULL) { fprintf(stderr, "terminal '%s', ", string_table+term_names); @@ -160,25 +132,12 @@ va_dcl /* VARARGS1 */ -#ifdef __STDC__ void syserr_abort(char *fmt, ...) -#else -syserr_abort(va_alist) -va_dcl -#endif { -#ifndef __STDC__ - register char *fmt; -#endif va_list args; -#ifdef __STDC__ va_start(args, fmt); -#else - va_start(args); - fmt = va_arg(args, char *); -#endif fprintf(stderr, "PROGRAM ERROR: Line %d: ", curr_line); if (string_table != NULL) { fprintf(stderr, "terminal '%s', ", string_table+term_names); diff --git a/usr/src/cmd/tic/tic_hash.c b/usr/src/cmd/tic/tic_hash.c index 093d2a036b..aa965a437f 100644 --- a/usr/src/cmd/tic/tic_hash.c +++ b/usr/src/cmd/tic/tic_hash.c @@ -19,11 +19,14 @@ * * CDDL HEADER END */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ - -/* +/* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved @@ -83,10 +86,12 @@ * */ +#include <strings.h> #include "curses_inc.h" #include "compiler.h" - +static void make_nte(void); +static int hash_function(char *); /* * make_hash_table() @@ -124,9 +129,10 @@ make_hash_table() /* * Make the name_table_entry from the capnames.c set of tables. */ -make_nte() +static void +make_nte(void) { - register int i, n; + int i, n; extern char *boolnames[], *numnames[], *strnames[]; n = 0; @@ -172,8 +178,7 @@ make_nte() * */ -static -int +static int hash_function(char *string) { long sum = 0; diff --git a/usr/src/cmd/tic/tic_main.c b/usr/src/cmd/tic/tic_main.c index c5ddc9b6e7..eac11a7e4a 100644 --- a/usr/src/cmd/tic/tic_main.c +++ b/usr/src/cmd/tic/tic_main.c @@ -20,8 +20,8 @@ * CDDL HEADER END */ /* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All Rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ @@ -105,6 +105,7 @@ extern void compile(); /* should be in a header file :-( */ extern void syserr_abort(); /* should be in a header file :-( */ static void init(); +int main(int argc, char *argv[]) { int i; diff --git a/usr/src/cmd/tic/tic_parse.c b/usr/src/cmd/tic/tic_parse.c index ebbc88dd50..d46ed50520 100644 --- a/usr/src/cmd/tic/tic_parse.c +++ b/usr/src/cmd/tic/tic_parse.c @@ -20,8 +20,8 @@ * CDDL HEADER END */ /* - * Copyright (c) 1996-1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ @@ -94,6 +94,8 @@ #include <stdio.h> #include <ctype.h> #include <stdlib.h> +#include <strings.h> +#include <unistd.h> #include "curses_inc.h" #include "compiler.h" #include "object.h" @@ -120,6 +122,10 @@ struct use_header { struct use_header use_list = {NULL, NULL}; int use_count = 0; +void dequeue(struct use_item *); +void init_structure(short Booleans[], short Numbers[], short Strings[]); +void dump_structure(short Booleans[], short Numbers[], short Strings[]); + /* * The use_list is a doubly-linked list with NULLs terminating the lists: * @@ -228,8 +234,8 @@ compile() } } -dump_list(str) -char *str; +void +dump_list(char *str) { struct use_item *ptr; char line[512]; @@ -277,8 +283,8 @@ do_entry(item_ptr) struct use_item *item_ptr; { long entry_offset; - register int token_type; - register struct name_table_entry *entry_ptr; + int token_type; + struct name_table_entry *entry_ptr; int found_forward_use = FALSE; short Booleans[MAXBOOLS], Numbers[MAXNUMS], @@ -375,12 +381,10 @@ struct use_item *item_ptr; have to be compatible with the pre-Vr3 format. */ #ifndef NOCANCELCOMPAT -elim_cancellations(Booleans, Numbers, Strings) -short Booleans[]; -short Numbers[]; -short Strings[]; +void +elim_cancellations(short Booleans[], short Numbers[], short Strings[]) { - register int i; + int i; for (i = 0; i < BoolCount; i++) { if (Booleans[i] == -2) Booleans[i] = FALSE; @@ -401,10 +405,10 @@ short Strings[]; Change the cancellation signal from the -2 used internally to the 2 used within the binary. */ -change_cancellations(Booleans) -short Booleans[]; +void +change_cancellations(short Booleans[]) { - register int i; + int i; for (i = 0; i < BoolCount; i++) { if (Booleans[i] == -2) Booleans[i] = 2; @@ -419,8 +423,8 @@ short Booleans[]; * */ -enqueue(offset) -long offset; +void +enqueue(long offset) { struct use_item *item; @@ -451,8 +455,8 @@ long offset; * */ -dequeue(ptr) -struct use_item *ptr; +void +dequeue(struct use_item *ptr) { if (ptr->fptr == NULL) use_list.tail = ptr->bptr; @@ -480,8 +484,8 @@ struct use_item *ptr; * */ -static int invalid_term_name(name) -register char *name; +static int +invalid_term_name(char *name) { int error = 0; if (! isdigit(*name) && ! islower(*name) && ! isupper(*name)) @@ -519,15 +523,13 @@ register char *name; * */ -dump_structure(Booleans, Numbers, Strings) -short Booleans[]; -short Numbers[]; -short Strings[]; +void +dump_structure(short Booleans[], short Numbers[], short Strings[]) { struct stat64 statbuf; FILE *fp; char name_list[1024]; - register char *first_name, *other_names, *cur_name; + char *first_name, *other_names, *cur_name; char filename[128 + 2 + 1]; char linkname[128 + 2 + 1]; int len; @@ -689,9 +691,9 @@ short Strings[]; char *namelist; short namelen; char zero = '\0'; - register int i; + int i; char cBooleans[MAXBOOLS]; - register int l_next_free; + int l_next_free; namelist = term_names + string_table; namelen = strlen(namelist) + 1; @@ -800,9 +802,8 @@ char *string; * */ -init_structure(Booleans, Numbers, Strings) -short Booleans[]; -short Numbers[], Strings[]; +void +init_structure(short Booleans[], short Numbers[], short Strings[]) { int i; diff --git a/usr/src/cmd/tic/tic_scan.c b/usr/src/cmd/tic/tic_scan.c index d669d91ac4..7e8339328d 100644 --- a/usr/src/cmd/tic/tic_scan.c +++ b/usr/src/cmd/tic/tic_scan.c @@ -20,8 +20,8 @@ * CDDL HEADER END */ /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ @@ -95,6 +95,10 @@ static int first_column; /* See 'next_char()' below */ +static void backspace(void); +void reset_input(void); +void panic_mode(int); + /* @@ -343,12 +347,13 @@ next_char() } -backspace() +static void +backspace(void) { curr_column--; if (curr_column < 0) - syserr_abort("Backspaced off beginning of line"); + syserr_abort("Backspaced off beginning of line"); } @@ -360,7 +365,8 @@ backspace() * */ -reset_input() +void +reset_input(void) { curr_column = -1; } @@ -496,9 +502,10 @@ trans_string(char *ptr) /* * Panic mode error recovery - skip everything until a "ch" is found. */ +void panic_mode(int ch) { - register int c; + int c; for (;;) { c = next_char(); diff --git a/usr/src/cmd/utmp_update/utmp_update.c b/usr/src/cmd/utmp_update/utmp_update.c index 1b99fb9d48..20e7c6a694 100644 --- a/usr/src/cmd/utmp_update/utmp_update.c +++ b/usr/src/cmd/utmp_update/utmp_update.c @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -43,20 +43,20 @@ /* * Header files */ -#include <stdio.h> -#include <sys/param.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <utmpx.h> -#include <errno.h> -#include <fcntl.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> -#include <pwd.h> -#include <ctype.h> -#include <stropts.h> -#include <syslog.h> +#include <stdio.h> +#include <sys/param.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <utmpx.h> +#include <errno.h> +#include <fcntl.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <pwd.h> +#include <ctype.h> +#include <stropts.h> +#include <syslog.h> /* * Invocation argument definitions @@ -118,8 +118,6 @@ main(int argc, char *argv[]) { struct utmpx *rutmpx; struct utmpx entryx; - int error = 0; - int num_args; #ifdef DEBUG int debugger = 1; printf("%d\n", getpid()); @@ -135,7 +133,7 @@ main(int argc, char *argv[]) if (argc != UTMPX_NARGS) { usage(); - exit(BAD_ARGS); + return (BAD_ARGS); } /* * we should never be called by root the code in libc already @@ -147,7 +145,7 @@ main(int argc, char *argv[]) */ if (getuid() == ROOT_UID) { usage(); - exit(ILLEGAL_ARGUMENT); + return (ILLEGAL_ARGUMENT); } /* * Search for matching entry by line name before put operation @@ -173,7 +171,7 @@ main(int argc, char *argv[]) if (rutmpx->ut_type == USER_PROCESS) { if (invalid_utmpx(&entryx, rutmpx)) { usage(); - exit(ILLEGAL_ARGUMENT); + return (ILLEGAL_ARGUMENT); } else { break; } @@ -182,9 +180,9 @@ main(int argc, char *argv[]) } if (pututxline(&entryx) == (struct utmpx *)NULL) { - exit(PUTUTXLINE_FAILURE); + return (PUTUTXLINE_FAILURE); } - exit(NORMAL_EXIT); + return (NORMAL_EXIT); } static int @@ -196,10 +194,10 @@ hex2bin(unsigned char c) return (10 + c - 'A'); else if ('a' <= c && c <= 'f') return (10 + c - 'a'); - else { - dprintf("Bad hex character: 0x%x\n", c); - exit(ILLEGAL_ARGUMENT); - } + + dprintf("Bad hex character: 0x%x\n", c); + exit(ILLEGAL_ARGUMENT); + /* NOTREACHED */ } @@ -297,7 +295,6 @@ check_utmpx(struct utmpx *entryx) char *line = buf; struct passwd *pwd; int uid; - int fd; int hostlen; char *user; uid_t ruid = getuid(); @@ -325,7 +322,7 @@ check_utmpx(struct utmpx *entryx) if (ruid != uid) { dprintf3("Bad uid: user %s = %d uid = %d \n", - entryx->ut_user, uid, getuid()); + entryx->ut_user, uid, getuid()); exit(ILLEGAL_ARGUMENT); } @@ -338,7 +335,7 @@ check_utmpx(struct utmpx *entryx) * Only USER_PROCESS and DEAD_PROCESS entries may be updated */ if (!(entryx->ut_type == USER_PROCESS || - entryx->ut_type == DEAD_PROCESS)) { + entryx->ut_type == DEAD_PROCESS)) { dprintf("Bad type type = %d\n", entryx->ut_type); exit(ILLEGAL_ARGUMENT); } @@ -406,7 +403,6 @@ bad_hostname(char *name, int len) static void check_id(char *id, char *line) { - char temp[4]; int i, len; if (id[1] == '/' && id[2] == 's' && id[3] == 't') { @@ -435,8 +431,8 @@ invalid_utmpx(struct utmpx *eutmpx, struct utmpx *rutmpx) #define SUTMPX_USER (sizeof (eutmpx->ut_user)) return (!nonuserx(*rutmpx) || - strncmp(eutmpx->ut_id, rutmpx->ut_id, SUTMPX_ID) != 0 || - strncmp(eutmpx->ut_user, rutmpx->ut_user, SUTMPX_USER) != 0); + strncmp(eutmpx->ut_id, rutmpx->ut_id, SUTMPX_ID) != 0 || + strncmp(eutmpx->ut_user, rutmpx->ut_user, SUTMPX_USER) != 0); } static int @@ -486,7 +482,7 @@ bad_line(char *line) /* * It really is a tty, so return success */ - close(fd); + (void) close(fd); if (seteuid(ROOT_UID) != 0) return (1); return (0); @@ -498,7 +494,7 @@ bad_line(char *line) */ if ((fstat(fd, &statbuf) < 0) || (statbuf.st_mode & S_IFCHR) == 0) { dprintf("Bad line (fstat failed) (Not S_IFCHR) = %s\n", line); - close(fd); + (void) close(fd); return (1); } @@ -507,7 +503,7 @@ bad_line(char *line) */ if (isastream(fd) != 1) { dprintf("Bad line (isastream failed) = %s\n", line); - close(fd); + (void) close(fd); return (1); } @@ -518,23 +514,23 @@ bad_line(char *line) */ if (ioctl(fd, I_PUSH, "ptem") == -1) { dprintf("Bad line (I_PUSH of \"ptem\" failed) = %s\n", line); - close(fd); + (void) close(fd); return (1); } if (isatty(fd) != 1) { dprintf("Bad line (isatty failed) = %s\n", line); - close(fd); + (void) close(fd); return (1); } if (ioctl(fd, I_POP, 0) == -1) { dprintf("Bad line (I_POP of \"ptem\" failed) = %s\n", line); - close(fd); + (void) close(fd); return (1); } - close(fd); + (void) close(fd); if (seteuid(ROOT_UID) != 0) return (1); @@ -572,8 +568,8 @@ fputmpx(struct utmpx *rutmpx) printf("ut_pid = \"%d\" \n", rutmpx->ut_pid); printf("ut_type = \"%d\" \n", rutmpx->ut_type); printf("ut_exit.e_termination = \"%d\" \n", - rutmpx->ut_exit.e_termination); + rutmpx->ut_exit.e_termination); printf("ut_exit.e_exit = \"%d\" \n", rutmpx->ut_exit.e_exit); } -#endif DEBUG +#endif /* DEBUG */ diff --git a/usr/src/cmd/utmpd/utmpd.c b/usr/src/cmd/utmpd/utmpd.c index 21bea43c20..7756e92549 100644 --- a/usr/src/cmd/utmpd/utmpd.c +++ b/usr/src/cmd/utmpd/utmpd.c @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -168,7 +168,7 @@ static int pidcmp(); /* For sorting pids */ static void clean_entry(); /* Removes entry from our table and calls ... */ static void clean_utmpx_ent(); /* Cleans a utmpx entry */ -static void fatal(); /* Prints error message and calls exit */ +static void fatal() __NORETURN; /* Prints error message and calls exit */ static void nonfatal(); /* Prints error message */ static void print_tables(); /* Prints out internal tables for Debug */ static int proc_is_alive(pid_t pid); /* Check if a process is alive */ @@ -178,13 +178,12 @@ static void warn_utmp(void); * main() - Main does basic setup and calls wait_for_pids() to do the work */ -void +int main(argc, argv) char **argv; { char *defp; struct rlimit rlim; - char tstr[80]; int i; time_t curtime, now; @@ -205,7 +204,7 @@ main(argc, argv) "%s: Wrong number of arguments\n", prog_name); (void) fprintf(stderr, "Usage: %s [-debug]\n", prog_name); - exit(-1); + exit(2); } } @@ -221,7 +220,7 @@ main(argc, argv) if ((defp = defread("WTMPX_UPDATE_FREQ=")) != NULL) { WTMPX_ufreq = atol(defp); dprintf(("WTMPX update frequency set to %d\n", - WTMPX_ufreq)); + WTMPX_ufreq)); } /* @@ -308,6 +307,7 @@ main(argc, argv) * We only get here if we had a bunch of resets - so give up */ fatal("Too many resets, giving up"); + return (1); } /* @@ -448,12 +448,12 @@ wait_for_pids() if (pread(pfd->fd, &psinfo, sizeof (psinfo), (off_t)0) != sizeof (psinfo)) { dprintf(("! %d: terminated, status 0x%.4x\n", \ - (int)pidtable[i].pl_pid, psinfo.pr_wstat)); + (int)pidtable[i].pl_pid, psinfo.pr_wstat)); pidtable[i].pl_status = psinfo.pr_wstat; } else { dprintf(("! %d: terminated\n", \ - (int)pidtable[i].pl_pid)); + (int)pidtable[i].pl_pid)); pidtable[i].pl_status = 0; } /* @@ -470,9 +470,7 @@ wait_for_pids() */ if (pfd->revents & (POLLNVAL|POLLERR)) { dprintf(("Poll Err = %d pid = %d i = %d\n", \ - pfd->revents, \ - (int)pidtable[i].pl_pid, i)); - + pfd->revents, (int)pidtable[i].pl_pid, i)); pid = pidtable[i].pl_pid; /* Save pid for below */ /* @@ -649,7 +647,7 @@ drain_pipe() } dprintf(("drain_pipe: Recd command %d, pid %d\n", - p->pd_type, (int)p->pd_pid)); + p->pd_type, (int)p->pd_pid)); switch (p->pd_type) { case ADDPID: /* @@ -976,13 +974,13 @@ fatal(char *str) { int oerrno = errno; - syslog(LOG_ALERT, str); + syslog(LOG_ALERT, "%s", str); if (Debug == 1) { if ((errno = oerrno) != 0) perror(prog_name); dprintf(("%s\n", str)); } - exit(-1); + exit(1); } /* @@ -992,7 +990,7 @@ fatal(char *str) static void nonfatal(char *str) { - syslog(LOG_WARNING, str); + syslog(LOG_WARNING, "%s", str); if (Debug == 1) { if (errno != 0) |