svn commit: r334553 - head/usr.bin/top
Eitan Adler
eadler at FreeBSD.org
Sun Jun 3 05:20:14 UTC 2018
Author: eadler
Date: Sun Jun 3 05:20:11 2018
New Revision: 334553
URL: https://svnweb.freebsd.org/changeset/base/334553
Log:
top(1): partial revert of r334517
In fixing issues with uid > INT_MAX, I broke the uid without username
case. The latter is more important so return the old state.
Discussed with: allanjude
Modified:
head/usr.bin/top/machine.c
head/usr.bin/top/machine.h
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 Sun Jun 3 05:07:46 2018 (r334552)
+++ head/usr.bin/top/machine.c Sun Jun 3 05:20:11 2018 (r334553)
@@ -918,7 +918,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)(uid_t), int flags)
+format_next_process(caddr_t xhandle, char *(*get_userid)(int), int flags)
{
struct kinfo_proc *pp;
const struct kinfo_proc *oldp;
Modified: head/usr.bin/top/machine.h
==============================================================================
--- head/usr.bin/top/machine.h Sun Jun 3 05:07:46 2018 (r334552)
+++ head/usr.bin/top/machine.h Sun Jun 3 05:20:11 2018 (r334553)
@@ -76,7 +76,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)(uid_t),
+char *format_next_process(caddr_t handle, char *(*get_userid)(int),
int flags);
void toggle_pcpustats(void);
void get_system_info(struct system_info *si);
Modified: head/usr.bin/top/top.c
==============================================================================
--- head/usr.bin/top/top.c Sun Jun 3 05:07:46 2018 (r334552)
+++ head/usr.bin/top/top.c Sun Jun 3 05:20:11 2018 (r334553)
@@ -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)(uid_t) = username;
+ char *(*get_userid)(int) = username;
char *uname_field = "USERNAME";
char *header_text;
char *env_top;
Modified: head/usr.bin/top/username.c
==============================================================================
--- head/usr.bin/top/username.c Sun Jun 3 05:07:46 2018 (r334552)
+++ head/usr.bin/top/username.c Sun Jun 3 05:20:11 2018 (r334553)
@@ -37,27 +37,26 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include "utils.h"
#include "username.h"
struct hash_el {
- uid_t uid;
+ int uid;
char name[MAXLOGNAME];
};
#define is_empty_hash(x) (hash_table[x].name[0] == 0)
/* simple minded hashing function */
-#define hashit(i) (i % Table_size)
+#define hashit(i) (abs(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(uid_t uid)
+char *username(int uid)
{
int hashindex;
@@ -70,7 +69,7 @@ char *username(uid_t uid)
return(hash_table[hashindex].name);
}
-uid_t userid(char username[])
+int userid(char username[])
{
struct passwd *pwd;
@@ -91,7 +90,7 @@ uid_t userid(char username[])
}
/* wecare 1 = enter it always, 0 = nice to have */
-int enter_user(uid_t uid, char name[], bool wecare)
+int enter_user(int uid, char name[], bool wecare)
{
int hashindex;
@@ -122,7 +121,7 @@ int enter_user(uid_t uid, char name[], bool wecare)
*/
int
-get_user(uid_t uid)
+get_user(int uid)
{
struct passwd *pwd;
Modified: head/usr.bin/top/username.h
==============================================================================
--- head/usr.bin/top/username.h Sun Jun 3 05:07:46 2018 (r334552)
+++ head/usr.bin/top/username.h Sun Jun 3 05:20:11 2018 (r334553)
@@ -12,13 +12,12 @@
#define USERNAME_H
#include <stdbool.h>
-#include <unistd.h>
-int enter_user(uid_t uid, char *name, bool wecare);
-int get_user(uid_t uid);
+int enter_user(int uid, char *name, bool wecare);
+int get_user(int uid);
void init_hash(void);
-char *username(uid_t uid);
-uid_t userid(char *username);
+char *username(int uid);
+int 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 Sun Jun 3 05:07:46 2018 (r334552)
+++ head/usr.bin/top/utils.c Sun Jun 3 05:20:11 2018 (r334553)
@@ -89,12 +89,12 @@ char *itoa(unsigned int val)
}
/*
- * itoa7(val) - like itoa, except the number is right justified in a 7
+ * (val) - like itoa, except the number is right justified in a 7
* character field. This code is a duplication of itoa instead of
* a front end to a more general routine for efficiency.
*/
-char *itoa7(unsigned int val)
+char *itoa7(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 Sun Jun 3 05:07:46 2018 (r334552)
+++ head/usr.bin/top/utils.h Sun Jun 3 05:20:11 2018 (r334553)
@@ -14,7 +14,7 @@
int atoiwi(const char *);
char *itoa(unsigned int);
-char *itoa7(unsigned int);
+char *itoa7(int);
int digits(int);
char **argparse(char *, int *);
long percentages(int, int *, long *, long *, long *);
More information about the svn-src-all
mailing list