svn commit: r334517 - head/usr.bin/top
Eitan Adler
eadler at FreeBSD.org
Sat Jun 2 03:54:53 UTC 2018
Author: eadler
Date: Sat Jun 2 03:54:50 2018
New Revision: 334517
URL: https://svnweb.freebsd.org/changeset/base/334517
Log:
top(1): Use uid_t for uid rather than 'int'
Remove unneeded define while here.
Modified:
head/usr.bin/top/machine.c
head/usr.bin/top/machine.h
head/usr.bin/top/screen.c
head/usr.bin/top/top.c
head/usr.bin/top/username.c
head/usr.bin/top/username.h
head/usr.bin/top/utils.c
head/usr.bin/top/utils.h
Modified: head/usr.bin/top/machine.c
==============================================================================
--- head/usr.bin/top/machine.c Sat Jun 2 03:33:02 2018 (r334516)
+++ head/usr.bin/top/machine.c Sat Jun 2 03:54:50 2018 (r334517)
@@ -914,7 +914,7 @@ get_process_info(struct system_info *si, struct proces
static char fmt[512]; /* static area where result is built */
char *
-format_next_process(caddr_t xhandle, char *(*get_userid)(int), int flags)
+format_next_process(caddr_t xhandle, char *(*get_userid)(uid_t), int flags)
{
struct kinfo_proc *pp;
const struct kinfo_proc *oldp;
Modified: head/usr.bin/top/machine.h
==============================================================================
--- head/usr.bin/top/machine.h Sat Jun 2 03:33:02 2018 (r334516)
+++ head/usr.bin/top/machine.h Sat Jun 2 03:54:50 2018 (r334517)
@@ -75,7 +75,7 @@ struct process_select
/* routines defined by the machine dependent module */
char *format_header(char *uname_field);
-char *format_next_process(caddr_t handle, char *(*get_userid)(int),
+char *format_next_process(caddr_t handle, char *(*get_userid)(uid_t),
int flags);
void toggle_pcpustats(void);
void get_system_info(struct system_info *si);
Modified: head/usr.bin/top/screen.c
==============================================================================
--- head/usr.bin/top/screen.c Sat Jun 2 03:33:02 2018 (r334516)
+++ head/usr.bin/top/screen.c Sat Jun 2 03:54:50 2018 (r334517)
@@ -25,7 +25,6 @@
#include <sys/ioctl.h>
#include <stdlib.h>
#include <string.h>
-#define TERMIOS
#include <termios.h>
#include <curses.h>
#include <termcap.h>
Modified: head/usr.bin/top/top.c
==============================================================================
--- head/usr.bin/top/top.c Sat Jun 2 03:33:02 2018 (r334516)
+++ head/usr.bin/top/top.c Sat Jun 2 03:54:50 2018 (r334517)
@@ -206,7 +206,7 @@ main(int argc, char *argv[])
int displays = 0; /* indicates unspecified */
int sel_ret = 0;
time_t curr_time;
- char *(*get_userid)(int) = username;
+ char *(*get_userid)(uid_t) = username;
char *uname_field = "USERNAME";
char *header_text;
char *env_top;
Modified: head/usr.bin/top/username.c
==============================================================================
--- head/usr.bin/top/username.c Sat Jun 2 03:33:02 2018 (r334516)
+++ head/usr.bin/top/username.c Sat Jun 2 03:54:50 2018 (r334517)
@@ -37,29 +37,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "utils.h"
#include "username.h"
struct hash_el {
- int uid;
+ uid_t uid;
char name[MAXLOGNAME];
};
#define is_empty_hash(x) (hash_table[x].name[0] == 0)
/* simple minded hashing function */
-/* Uid "nobody" is -2 results in hashit(-2) = -2 which is out of bounds for
- the hash_table. Applied abs() function to fix. 2/16/96 tpugh
-*/
-#define hashit(i) (abs(i) % Table_size)
+#define hashit(i) (i % Table_size)
/* K&R requires that statically declared tables be initialized to zero. */
/* We depend on that for hash_table and YOUR compiler had BETTER do it! */
static struct hash_el hash_table[Table_size];
-char *username(int uid)
+char *username(uid_t uid)
{
int hashindex;
@@ -72,7 +70,7 @@ char *username(int uid)
return(hash_table[hashindex].name);
}
-int userid(char username[])
+uid_t userid(char username[])
{
struct passwd *pwd;
@@ -93,7 +91,7 @@ int userid(char username[])
}
/* wecare 1 = enter it always, 0 = nice to have */
-int enter_user(int uid, char name[], bool wecare)
+int enter_user(uid_t uid, char name[], bool wecare)
{
int hashindex;
@@ -124,7 +122,7 @@ int enter_user(int uid, char name[], bool wecare)
*/
int
-get_user(int uid)
+get_user(uid_t uid)
{
struct passwd *pwd;
Modified: head/usr.bin/top/username.h
==============================================================================
--- head/usr.bin/top/username.h Sat Jun 2 03:33:02 2018 (r334516)
+++ head/usr.bin/top/username.h Sat Jun 2 03:54:50 2018 (r334517)
@@ -12,12 +12,13 @@
#define USERNAME_H
#include <stdbool.h>
+#include <unistd.h>
-int enter_user(int uid, char *name, bool wecare);
-int get_user(int uid);
+int enter_user(uid_t uid, char *name, bool wecare);
+int get_user(uid_t uid);
void init_hash(void);
-char *username(int uid);
-int userid(char *username);
+char *username(uid_t uid);
+uid_t userid(char *username);
/*
* "Table_size" defines the size of the hash tables used to map uid to
Modified: head/usr.bin/top/utils.c
==============================================================================
--- head/usr.bin/top/utils.c Sat Jun 2 03:33:02 2018 (r334516)
+++ head/usr.bin/top/utils.c Sat Jun 2 03:54:50 2018 (r334517)
@@ -59,7 +59,7 @@ atoiwi(char *str)
*/
_Static_assert(sizeof(int) <= 4, "buffer too small for this sized int");
-char *itoa(int val)
+char *itoa(unsigned int val)
{
char *ptr;
static char buffer[16]; /* result is built here */
@@ -87,7 +87,7 @@ char *itoa(int val)
* a front end to a more general routine for efficiency.
*/
-char *itoa7(int val)
+char *itoa7(unsigned int val)
{
char *ptr;
static char buffer[16]; /* result is built here */
Modified: head/usr.bin/top/utils.h
==============================================================================
--- head/usr.bin/top/utils.h Sat Jun 2 03:33:02 2018 (r334516)
+++ head/usr.bin/top/utils.h Sat Jun 2 03:54:50 2018 (r334517)
@@ -11,8 +11,8 @@
*/
int atoiwi(char *);
-char *itoa(int);
-char *itoa7(int);
+char *itoa(unsigned int);
+char *itoa7(unsigned int);
int digits(int);
char *strecpy(char *, char *);
char **argparse(char *, int *);
More information about the svn-src-head
mailing list