From cdc5a29bb51a8e433c413b9d5c562f158f00193d Mon Sep 17 00:00:00 2001 From: millert Date: Thu, 13 Sep 2018 15:23:32 +0000 Subject: [PATCH] Fix warnings caused by user_from_uid() and group_from_gid() now returning const char *. --- bin/ls/ls.c | 5 +++-- usr.bin/fstat/fstat.c | 4 ++-- usr.bin/ssh/sftp-common.c | 4 ++-- usr.bin/systat/pigs.c | 4 ++-- usr.bin/top/machine.c | 4 ++-- usr.bin/top/machine.h | 4 ++-- usr.bin/top/top.c | 4 ++-- usr.bin/top/top.h | 4 ++-- usr.bin/top/username.c | 4 ++-- usr.bin/top/utils.c | 4 ++-- usr.bin/top/utils.h | 4 ++-- usr.sbin/user/user.c | 4 ++-- 12 files changed, 25 insertions(+), 24 deletions(-) diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 1e28c9fe213..d7bef994aeb 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ls.c,v 1.50 2018/02/04 22:09:33 deraadt Exp $ */ +/* $OpenBSD: ls.c,v 1.51 2018/09/13 15:23:32 millert Exp $ */ /* $NetBSD: ls.c,v 1.18 1996/07/09 09:16:29 mycroft Exp $ */ /* @@ -431,8 +431,9 @@ display(FTSENT *p, FTSENT *list) int bcfile, flen, glen, ulen, maxflags, maxgroup, maxuser, maxlen; int entries, needstats; int width; - char *user, *group, buf[21]; /* 64 bits == 20 digits */ + const char *user, *group; char nuser[12], ngroup[12]; + char buf[21]; /* 64 bits == 20 digits */ char *flags = NULL; /* diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 90e8f4fc5ee..783fda718d5 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fstat.c,v 1.93 2018/04/10 11:09:14 sthen Exp $ */ +/* $OpenBSD: fstat.c,v 1.94 2018/09/13 15:23:32 millert Exp $ */ /* * Copyright (c) 2009 Todd C. Miller @@ -331,7 +331,7 @@ fstat_header(void) putchar('\n'); } -char *Uname, *Comm; +const char *Uname, *Comm; uid_t *procuid; pid_t Pid; diff --git a/usr.bin/ssh/sftp-common.c b/usr.bin/ssh/sftp-common.c index c62940441cc..ba8efbfde48 100644 --- a/usr.bin/ssh/sftp-common.c +++ b/usr.bin/ssh/sftp-common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-common.c,v 1.30 2017/06/10 06:36:46 djm Exp $ */ +/* $OpenBSD: sftp-common.c,v 1.31 2018/09/13 15:23:32 millert Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * Copyright (c) 2001 Damien Miller. All rights reserved. @@ -211,7 +211,7 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units) { int ulen, glen, sz = 0; struct tm *ltime = localtime(&st->st_mtime); - char *user, *group; + const char *user, *group; char buf[1024], lc[8], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1]; char sbuf[FMT_SCALED_STRSIZE]; time_t now; diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c index f9af1b0e111..71144ba6dc2 100644 --- a/usr.bin/systat/pigs.c +++ b/usr.bin/systat/pigs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pigs.c,v 1.30 2015/09/12 15:59:36 deraadt Exp $ */ +/* $OpenBSD: pigs.c,v 1.31 2018/09/13 15:23:32 millert Exp $ */ /* $NetBSD: pigs.c,v 1.3 1995/04/29 05:54:50 cgd Exp $ */ /*- @@ -255,7 +255,7 @@ showpigs(int k) { struct kinfo_proc *kp; double value; - char *uname, *pname; + const char *uname, *pname; if (procbase == NULL) return; diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 4643778a15c..2926ec2133b 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.c,v 1.90 2018/05/14 12:31:21 mpi Exp $ */ +/* $OpenBSD: machine.c,v 1.91 2018/09/13 15:23:32 millert Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert @@ -545,7 +545,7 @@ format_comm(struct kinfo_proc *kp) } char * -format_next_process(caddr_t hndl, char *(*get_userid)(uid_t), pid_t *pid, +format_next_process(caddr_t hndl, const char *(*get_userid)(uid_t), pid_t *pid, int show_threads) { char *p_wait; diff --git a/usr.bin/top/machine.h b/usr.bin/top/machine.h index eeb10deeee5..4c7c62b78dc 100644 --- a/usr.bin/top/machine.h +++ b/usr.bin/top/machine.h @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.h,v 1.20 2015/05/06 07:53:29 mpi Exp $ */ +/* $OpenBSD: machine.h,v 1.21 2018/09/13 15:23:32 millert Exp $ */ /* * Top users/processes display for Unix @@ -89,7 +89,7 @@ extern void get_system_info(struct system_info *); extern caddr_t get_process_info(struct system_info *, struct process_select *, int (*) (const void *, const void *)); -extern char *format_next_process(caddr_t, char *(*)(uid_t), pid_t *, int); +extern char *format_next_process(caddr_t, const char *(*)(uid_t), pid_t *, int); extern uid_t proc_owner(pid_t); extern struct kinfo_proc *getprocs(int, int, int *); diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index d3ed70e65f1..178696ba792 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -1,4 +1,4 @@ -/* $OpenBSD: top.c,v 1.90 2018/07/29 13:34:26 deraadt Exp $ */ +/* $OpenBSD: top.c,v 1.91 2018/09/13 15:23:32 millert Exp $ */ /* * Top users/processes display for Unix @@ -279,7 +279,7 @@ int main(int argc, char *argv[]) { char *uname_field = "USERNAME", *header_text, *env_top; - char *(*get_userid)(uid_t) = username; + const char *(*get_userid)(uid_t) = username; char **preset_argv = NULL, **av = argv; int preset_argc = 0, ac = argc, active_procs, i; sigset_t mask, oldmask; diff --git a/usr.bin/top/top.h b/usr.bin/top/top.h index 16dfb7ae6ab..e54474f4cdb 100644 --- a/usr.bin/top/top.h +++ b/usr.bin/top/top.h @@ -1,4 +1,4 @@ -/* $OpenBSD: top.h,v 1.15 2013/09/21 14:15:19 espie Exp $ */ +/* $OpenBSD: top.h,v 1.16 2018/09/13 15:23:32 millert Exp $ */ /* * Top users/processes display for Unix @@ -78,5 +78,5 @@ extern char *renice_procs(char *); extern void quit(int); /* username.c */ -extern char *username(uid_t); +extern const char *username(uid_t); extern uid_t userid(char *); diff --git a/usr.bin/top/username.c b/usr.bin/top/username.c index b53e1c1a0b9..21d8d396efa 100644 --- a/usr.bin/top/username.c +++ b/usr.bin/top/username.c @@ -1,4 +1,4 @@ -/* $OpenBSD: username.c,v 1.17 2015/10/26 13:56:18 tedu Exp $ */ +/* $OpenBSD: username.c,v 1.18 2018/09/13 15:23:32 millert Exp $ */ /* * Top users/processes display for Unix @@ -41,7 +41,7 @@ #include "top.h" #include "utils.h" -char * +const char * username(uid_t uid) { return user_from_uid(uid, 0); diff --git a/usr.bin/top/utils.c b/usr.bin/top/utils.c index cb21df164b5..9e7f9cce41b 100644 --- a/usr.bin/top/utils.c +++ b/usr.bin/top/utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.c,v 1.26 2017/03/15 04:24:14 deraadt Exp $ */ +/* $OpenBSD: utils.c,v 1.27 2018/09/13 15:23:32 millert Exp $ */ /* * Top users/processes display for Unix @@ -88,7 +88,7 @@ itoa(int val) * format_uid(uid) - like itoa, except for uid_t and the number is right * justified in a 6 character field to match uname_field in top.c. */ -char * +const char * format_uid(uid_t uid) { static char buffer[16]; /* result is built here */ diff --git a/usr.bin/top/utils.h b/usr.bin/top/utils.h index e38e4b2f593..034d2f62c60 100644 --- a/usr.bin/top/utils.h +++ b/usr.bin/top/utils.h @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.h,v 1.8 2005/06/08 22:36:43 millert Exp $ */ +/* $OpenBSD: utils.h,v 1.9 2018/09/13 15:23:32 millert Exp $ */ /* * Top users/processes display for Unix @@ -32,7 +32,7 @@ int atoiwi(char *); char *itoa(int); -char *format_uid(uid_t); +const char *format_uid(uid_t); int digits(int); int string_index(char *, char **); char **argparse(char *, int *); diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c index d1458ed5b38..d8c1b34a3ef 100644 --- a/usr.sbin/user/user.c +++ b/usr.sbin/user/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.120 2017/05/24 09:18:15 mestre Exp $ */ +/* $OpenBSD: user.c,v 1.121 2018/09/13 15:23:32 millert Exp $ */ /* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */ /* @@ -507,7 +507,7 @@ append_group(char *user, int ngroups, const char **groups) char buf[LINE_MAX]; char f[MaxFileNameLen]; char *colon; - char *ugid = NULL; + const char *ugid = NULL; int fd; int cc; int i; -- 2.20.1