Remove uses of some deprecated functions.

This commit is contained in:
mycroft 1995-03-22 15:56:29 +00:00
parent 7f3235feb5
commit dd94184a46
3 changed files with 28 additions and 28 deletions

View File

@ -33,7 +33,7 @@ static char copright[] =
"@(#) Copyright (c) 1994 Christopher G. Demetriou\n\
All rights reserved.\n";
static char rcsid[] = "$Id: main.c,v 1.3 1995/03/22 15:49:18 mycroft Exp $";
static char rcsid[] = "$Id: main.c,v 1.4 1995/03/22 15:56:29 mycroft Exp $";
#endif
/*
@ -68,7 +68,7 @@ int Kflag, lflag, mflag, qflag, rflag, sflag, tflag, uflag, vflag;
int cutoff = 1;
static char *dfltargv[] = { _PATH_ACCT };
static int dfltargc = (sizeof dfltargv/sizeof(char *));
static int dfltargc = (sizeof(dfltargv)/sizeof(char *));
/* default to comparing by sum of user + system time */
cmpf_t sa_cmp = cmp_usrsys;
@ -322,7 +322,7 @@ acct_load(pn, wr)
/* decode it */
ci.ci_calls = 1;
for (i = 0; i < sizeof ac.ac_comm && ac.ac_comm[i] != '\0';
for (i = 0; i < sizeof(ac.ac_comm) && ac.ac_comm[i] != '\0';
i++) {
char c = ac.ac_comm[i];

View File

@ -29,7 +29,7 @@
*/
#ifndef LINT
static char rcsid[] = "$Id: pdb.c,v 1.2 1994/12/23 16:50:06 cgd Exp $";
static char rcsid[] = "$Id: pdb.c,v 1.3 1995/03/22 15:56:31 mycroft Exp $";
#endif
#include <sys/types.h>
@ -118,10 +118,10 @@ pacct_add(ci)
{
DBT key, data;
struct cmdinfo newci;
char keydata[sizeof ci->ci_comm];
char keydata[sizeof(ci->ci_comm)];
int rv;
bcopy(ci->ci_comm, &keydata, sizeof keydata);
memcpy(&keydata, ci->ci_comm, sizeof(keydata));
key.data = &keydata;
key.size = strlen(keydata);
@ -132,16 +132,16 @@ pacct_add(ci)
} else if (rv == 0) { /* it's there; copy whole thing */
/* XXX compare size if paranoid */
/* add the old data to the new data */
bcopy(data.data, &newci, data.size);
memcpy(&newci, data.data, data.size);
} else { /* it's not there; zero it and copy the key */
bzero(&newci, sizeof newci);
bcopy(key.data, newci.ci_comm, key.size);
memset(&newci, 0, sizeof(newci));
memcpy(newci.ci_comm, key.data, key.size);
}
add_ci(ci, &newci);
data.data = &newci;
data.size = sizeof newci;
data.size = sizeof(newci);
rv = DB_PUT(pacct_db, &key, &data, 0);
if (rv < 0) {
warn("add key %s to process accounting stats", ci->ci_comm);
@ -212,18 +212,18 @@ pacct_print()
struct cmdinfo *cip, ci, ci_total, ci_other, ci_junk;
int rv;
bzero(&ci_total, sizeof ci_total);
memset(&ci_total, 0, sizeof(ci_total));
strcpy(ci_total.ci_comm, "");
bzero(&ci_other, sizeof ci_other);
memset(&ci_other, 0, sizeof(ci_other));
strcpy(ci_other.ci_comm, "***other");
bzero(&ci_junk, sizeof ci_junk);
memset(&ci_junk, 0, sizeof(ci_junk));
strcpy(ci_junk.ci_comm, "**junk**");
/*
* Retrieve them into new DB, sorted by appropriate key.
* At the same time, cull 'other' and 'junk'
*/
bzero(&bti, sizeof bti);
memset(&bti, 0, sizeof(bti));
bti.compare = sa_cmp;
output_pacct_db = dbopen(NULL, O_RDWR, 0, DB_BTREE, &bti);
if (output_pacct_db == NULL) {
@ -238,7 +238,7 @@ pacct_print()
warn("retrieving process accounting stats");
while (rv == 0) {
cip = (struct cmdinfo *) data.data;
bcopy(cip, &ci, sizeof ci);
memcpy(&ci, cip, sizeof(ci));
/* add to total */
add_ci(&ci, &ci_total);
@ -267,14 +267,14 @@ next: rv = DB_SEQ(pacct_db, &key, &data, R_NEXT);
/* insert **junk** and ***other */
if (ci_junk.ci_calls != 0) {
data.data = &ci_junk;
data.size = sizeof ci_junk;
data.size = sizeof(ci_junk);
rv = DB_PUT(output_pacct_db, &data, &ndata, 0);
if (rv < 0)
warn("sorting process accounting stats");
}
if (ci_other.ci_calls != 0) {
data.data = &ci_other;
data.size = sizeof ci_other;
data.size = sizeof(ci_other);
rv = DB_PUT(output_pacct_db, &data, &ndata, 0);
if (rv < 0)
warn("sorting process accounting stats");
@ -289,7 +289,7 @@ next: rv = DB_SEQ(pacct_db, &key, &data, R_NEXT);
warn("retrieving process accounting report");
while (rv == 0) {
cip = (struct cmdinfo *) data.data;
bcopy(cip, &ci, sizeof ci);
memcpy(&ci, cip, sizeof(ci));
print_ci(&ci, &ci_total);

View File

@ -29,7 +29,7 @@
*/
#ifndef LINT
static char rcsid[] = "$Id: usrdb.c,v 1.2 1995/03/08 21:39:03 pk Exp $";
static char rcsid[] = "$Id: usrdb.c,v 1.3 1995/03/22 15:56:33 mycroft Exp $";
#endif
#include <sys/types.h>
@ -51,7 +51,7 @@ usracct_init()
BTREEINFO bti;
int error;
bzero(&bti, sizeof bti);
memset(&bti, 0, sizeof(bti));
bti.compare = uid_compare;
usracct_db = dbopen(NULL, O_RDWR, 0, DB_BTREE, &bti);
@ -125,7 +125,7 @@ usracct_add(ci)
uid = ci->ci_uid;
key.data = &uid;
key.size = sizeof uid;
key.size = sizeof(uid);
rv = DB_GET(usracct_db, &key, &data, 0);
if (rv < 0) {
@ -133,7 +133,7 @@ usracct_add(ci)
return (-1);
} else if (rv == 0) { /* it's there; copy whole thing */
/* add the old data to the new data */
bcopy(data.data, &newui, data.size);
memcpy(&newui, data.data, data.size);
if (newui.ui_uid != uid) {
warnx("key %d != expected record number %d",
newui.ui_uid, uid);
@ -141,7 +141,7 @@ usracct_add(ci)
return (-1);
}
} else { /* it's not there; zero it and copy the key */
bzero(&newui, sizeof newui);
memset(&newui, 0, sizeof(newui));
newui.ui_uid = ci->ci_uid;
}
@ -152,7 +152,7 @@ usracct_add(ci)
newui.ui_io += ci->ci_io;
data.data = &newui;
data.size = sizeof newui;
data.size = sizeof(newui);
rv = DB_PUT(usracct_db, &key, &data, 0);
if (rv < 0) {
warn("add key %d to user accounting stats", uid);
@ -174,7 +174,7 @@ usracct_update()
u_long uid;
int error, serr, nerr;
bzero(&bti, sizeof bti);
memset(&bti, 0, sizeof(bti));
bti.compare = uid_compare;
saved_usracct_db = dbopen(_PATH_USRACCT, O_RDWR|O_CREAT|O_TRUNC, 0644,
@ -232,7 +232,7 @@ usracct_print()
warn("retrieving user accounting stats");
while (rv == 0) {
bcopy(data.data, ui, sizeof(struct userinfo));
memcpy(ui, data.data, sizeof(struct userinfo));
printf("%-8s %9qu ",
user_from_uid(ui->ui_uid, 0), ui->ui_calls);
@ -270,8 +270,8 @@ uid_compare(k1, k2)
{
u_long d1, d2;
bcopy(k1->data, &d1, sizeof d1);
bcopy(k2->data, &d2, sizeof d2);
memcpy(&d1, k1->data, sizeof(d1));
memcpy(&d2, k2->data, sizeof(d2));
if (d1 < d2)
return -1;