Commit 81a4a3d2 authored by albert's avatar albert

gcc 3.0 warnings

parent f86b39f4
......@@ -157,7 +157,7 @@ watch: % : %.o
############ progX --> progY
snice kill: skill
ln skill $@
ln -f skill $@
pkill: pgrep
ln pgrep pkill
ln -f pgrep pkill
......@@ -28,7 +28,7 @@
#include "proc/version.h" /* procps_version */
static int i_am_pkill = 0;
char *progname = "pgrep";
static const char *progname = "pgrep";
union el {
long num;
......@@ -44,7 +44,7 @@ static int opt_negate = 0;
static int opt_exact = 0;
static int opt_signal = SIGTERM;
static char *opt_delim = "\n";
static const char *opt_delim = "\n";
static union el *opt_pgrp = NULL;
static union el *opt_gid = NULL;
static union el *opt_ppid = NULL;
......
......@@ -175,7 +175,7 @@ static int guess_name(char * const buf, int maj, int min){
* Useful names could be in /proc/PID/fd/2 (stderr, seldom redirected)
* and in /proc/PID/fd/255 (used by bash to remember the tty).
*/
static int link_name(char * const buf, int maj, int min, int pid, char *name){
static int link_name(char * const buf, int maj, int min, int pid, const char *name){
struct stat sbuf;
char path[32];
int count;
......
......@@ -112,7 +112,7 @@ static const char dash[] = "-";
/* These mostly rely on POSIX to make them zero. */
static const symb hashtable[256];
static symb hashtable[256];
static char *sysmap_data;
static unsigned sysmap_room;
......@@ -123,7 +123,7 @@ static char *ksyms_data;
static unsigned ksyms_room = 4096;
static symb *ksyms_index;
static unsigned ksyms_count;
static int idx_room;
static unsigned idx_room;
/*********************************/
......
......@@ -29,8 +29,8 @@ unsigned print_str(FILE* file, char *s, unsigned max) {
to octal as we go, separating items of the list by 'sep' and stopping after
processing max chars of output (accounting for expansion due to octal rep).
*/
unsigned print_strlist(FILE* file, char **strs, char* sep, unsigned max) {
int i, n, seplen = strlen(sep);
unsigned print_strlist(FILE* file, char **strs, unsigned max) {
int i, n;
for (n=0; *strs && n < max; strs++) {
for (i=0; strs[0][i] && n+i < max; i++)
if (isprint(strs[0][i]) || strs[0][i] == ' ')
......@@ -43,9 +43,9 @@ unsigned print_strlist(FILE* file, char **strs, char* sep, unsigned max) {
return max - n;
}
n += i;
if (n + seplen < max) {
fputs(sep, file);
n += seplen;
if (n + 1 < max) {
fputc(' ', file);
n++;
} else
return max - n;
}
......
......@@ -23,4 +23,4 @@ extern int open_psdb(const char *override);
extern int open_psdb_message(const char *override, void (*message)(const char *, ...));
extern unsigned print_str (FILE* file, char *s, unsigned max);
extern unsigned print_strlist(FILE* file, char **strs, char* sep, unsigned max);
extern unsigned print_strlist(FILE* file, char **strs, unsigned max);
......@@ -211,7 +211,7 @@ static void statm2proc(char* s, proc_t* P) {
/* fprintf(stderr, "statm2proc converted %d fields.\n",num); */
}
static int file2str(char *directory, char *what, char *ret, int cap) {
static int file2str(const char *directory, const char *what, char *ret, int cap) {
static char filename[80];
int fd, num_read;
......@@ -223,7 +223,7 @@ static int file2str(char *directory, char *what, char *ret, int cap) {
return num_read;
}
static char** file2strvec(char* directory, char* what) {
static char** file2strvec(const char* directory, const char* what) {
char buf[2048]; /* read buf bytes at a time */
char *p, *rbuf = 0, *endbuf, **q, **ret;
int fd, tot = 0, n, c, end_of_file = 0;
......
......@@ -51,12 +51,12 @@
#endif
typedef struct mapstruct {
char *name;
const char *name;
int num;
} mapstruct;
static mapstruct sigtable[] = {
static const mapstruct sigtable[] = {
{"ABRT", SIGABRT}, /* IOT */
{"ALRM", SIGALRM},
{"BUS", SIGBUS},
......@@ -98,7 +98,7 @@ static mapstruct sigtable[] = {
static const int number_of_signals = sizeof(sigtable)/sizeof(mapstruct);
static int compare_signal_names(const void *a, const void *b){
return strcasecmp( ((mapstruct*)a)->name, ((mapstruct*)b)->name );
return strcasecmp( ((const mapstruct*)a)->name, ((const mapstruct*)b)->name );
}
/* return -1 on failure */
......
......@@ -281,11 +281,11 @@ void loadavg(double *av1, double *av5, double *av15) {
typedef struct mem_table_struct {
const char *name; /* memory type name */
const unsigned *slot; /* slot in return struct */
unsigned *slot; /* slot in return struct */
} mem_table_struct;
static int compare_mem_table_structs(const void *a, const void *b){
return strcmp(((mem_table_struct*)a)->name,((mem_table_struct*)b)->name);
return strcmp(((const mem_table_struct*)a)->name,((const mem_table_struct*)b)->name);
}
/* example data, following junk, with comments added:
......@@ -342,7 +342,6 @@ unsigned kb_main_used;
unsigned kb_writeback;
unsigned kb_slab;
unsigned nr_reversemaps;
unsigned kb_active;
unsigned kb_committed_as;
unsigned kb_dirty;
unsigned kb_inactive;
......@@ -385,7 +384,7 @@ void meminfo(void){
FILE_TO_BUF(MEMINFO_FILE,meminfo_fd);
kb_inactive = -1;
kb_inactive = ~0U;
head = buf;
for(;;){
......@@ -412,7 +411,7 @@ nextline:
kb_low_total = kb_main_total;
kb_low_free = kb_main_free;
}
if(kb_inactive==-1){
if(kb_inactive==~0U){
kb_inactive = kb_inact_dirty + kb_inact_clean;
}
kb_swap_used = kb_swap_total - kb_swap_free;
......@@ -425,11 +424,11 @@ nextline:
typedef struct vm_table_struct {
const char *name; /* VM statistic name */
const unsigned *slot; /* slot in return struct */
unsigned *slot; /* slot in return struct */
} vm_table_struct;
static int compare_vm_table_structs(const void *a, const void *b){
return strcmp(((vm_table_struct*)a)->name,((vm_table_struct*)b)->name);
return strcmp(((const vm_table_struct*)a)->name,((const vm_table_struct*)b)->name);
}
unsigned vm_nr_dirty;
......
......@@ -244,11 +244,11 @@ extern void reset_global(void);
/* global.c */
extern int all_processes;
extern char *bsd_j_format;
extern char *bsd_l_format;
extern char *bsd_s_format;
extern char *bsd_u_format;
extern char *bsd_v_format;
extern const char *bsd_j_format;
extern const char *bsd_l_format;
extern const char *bsd_s_format;
extern const char *bsd_u_format;
extern const char *bsd_v_format;
extern int bsd_c_option;
extern int bsd_e_option;
extern uid_t cached_euid;
......@@ -274,10 +274,10 @@ extern unsigned long seconds_since_boot;
extern selection_node *selection_list;
extern unsigned simple_select;
extern sort_node *sort_list;
extern char *sysv_f_format;
extern char *sysv_fl_format;
extern char *sysv_j_format;
extern char *sysv_l_format;
extern const char *sysv_f_format;
extern const char *sysv_fl_format;
extern const char *sysv_j_format;
extern const char *sysv_l_format;
extern int unix_f_option;
extern int user_is_number;
extern int wchan_is_number;
......
......@@ -288,7 +288,7 @@ static int compare_two_procs(const void *a, const void *b){
sort_node *tmp_list = sort_list;
while(tmp_list){
int result;
result = (*tmp_list->sr)(*(const proc_t **)a, *(const proc_t **)b);
result = (*tmp_list->sr)(*(const proc_t *const*)a, *(const proc_t *const*)b);
if(result) return (tmp_list->reverse) ? -result : result;
tmp_list = tmp_list->next;
}
......
......@@ -17,11 +17,7 @@
#include <grp.h>
#include <string.h>
/*#undef __GLIBC_MINOR__
#define __GLIBC_MINOR__ 1 */
#include "common.h"
/*#undef __GLIBC_MINOR__
#define __GLIBC_MINOR__ 0 */
#include <sys/sysmacros.h>
#include "../proc/version.h"
......@@ -39,14 +35,14 @@
#endif
static char *saved_personality_text = "You found a bug!";
static const char * saved_personality_text = "You found a bug!";
int all_processes = -1;
char *bsd_j_format = (char *)0xdeadbeef;
char *bsd_l_format = (char *)0xdeadbeef;
char *bsd_s_format = (char *)0xdeadbeef;
char *bsd_u_format = (char *)0xdeadbeef;
char *bsd_v_format = (char *)0xdeadbeef;
const char *bsd_j_format = (const char *)0xdeadbeef;
const char *bsd_l_format = (const char *)0xdeadbeef;
const char *bsd_s_format = (const char *)0xdeadbeef;
const char *bsd_u_format = (const char *)0xdeadbeef;
const char *bsd_v_format = (const char *)0xdeadbeef;
int bsd_c_option = -1;
int bsd_e_option = -1;
uid_t cached_euid = -1;
......@@ -71,10 +67,10 @@ unsigned long seconds_since_boot = -1;
selection_node *selection_list = (selection_node *)0xdeadbeef;
unsigned simple_select = 0xffffffff;
sort_node *sort_list = (sort_node *)0xdeadbeef; /* ready-to-use sort list */
char *sysv_f_format = (char *)0xdeadbeef;
char *sysv_fl_format = (char *)0xdeadbeef;
char *sysv_j_format = (char *)0xdeadbeef;
char *sysv_l_format = (char *)0xdeadbeef;
const char *sysv_f_format = (const char *)0xdeadbeef;
const char *sysv_fl_format = (const char *)0xdeadbeef;
const char *sysv_j_format = (const char *)0xdeadbeef;
const char *sysv_l_format = (const char *)0xdeadbeef;
int unix_f_option = -1;
int user_is_number = -1;
int wchan_is_number = -1;
......@@ -142,11 +138,11 @@ typedef struct personality_table_struct {
} personality_table_struct;
static int compare_personality_table_structs(const void *a, const void *b){
return strcasecmp(((personality_table_struct*)a)->name,((personality_table_struct*)b)->name);
return strcasecmp(((const personality_table_struct*)a)->name,((const personality_table_struct*)b)->name);
}
static const char *set_personality(void){
char *s;
const char *s;
size_t sl;
char buf[16];
personality_table_struct findme = { buf, NULL};
......
......@@ -833,7 +833,7 @@ static int pr_stime(void){
struct tm *proc_time;
struct tm *our_time;
time_t t;
char *fmt;
const char *fmt;
int tm_year;
int tm_yday;
our_time = localtime(&seconds_since_1970); /* not reentrant */
......@@ -1510,11 +1510,11 @@ void print_format_specifiers(void){
/************ comparison functions for bsearch *************/
static int compare_format_structs(const void *a, const void *b){
return strcmp(((format_struct*)a)->spec,((format_struct*)b)->spec);
return strcmp(((const format_struct*)a)->spec,((const format_struct*)b)->spec);
}
static int compare_macro_structs(const void *a, const void *b){
return strcmp(((macro_struct*)a)->spec,((macro_struct*)b)->spec);
return strcmp(((const macro_struct*)a)->spec,((const macro_struct*)b)->spec);
}
/******** look up structs as needed by the sort & format parsers ******/
......
......@@ -713,7 +713,7 @@ typedef struct gnu_table_struct {
} gnu_table_struct;
static int compare_gnu_table_structs(const void *a, const void *b){
return strcmp(((gnu_table_struct*)a)->name,((gnu_table_struct*)b)->name);
return strcmp(((const gnu_table_struct*)a)->name,((const gnu_table_struct*)b)->name);
}
/* Option arguments are after ':', after '=', or in argv[n+1] */
......
......@@ -93,7 +93,7 @@ static format_node *do_one_spec(const char *spec, const char *override){
static void O_wrap(sf_node *sfn, int otype){
format_node *fnode;
format_node *endp;
char *trailer;
const char *trailer;
trailer = (otype=='b') ? "END_BSD" : "END_SYS5" ;
......
......@@ -287,7 +287,7 @@ static char *strim (int sp, char *str)
* This guy just facilitates Batch and protects against dumb ttys
* -- we'd 'inline' him but he's only called twice per frame,
* yet used in many other locations. */
static char *tg2 (int x, int y)
static const char *tg2 (int x, int y)
{
return Cap_can_goto ? tgoto(cursor_address, x, y) : "";
}
......@@ -375,6 +375,7 @@ static void bye_bye (int eno, const char *str)
* SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT and SIGTERM */
static void stop (int dont_care_sig)
{
(void)dont_care_sig;
bye_bye(0, NULL);
}
......@@ -405,6 +406,7 @@ static void std_err (const char *str)
* SIGTSTP, SIGTTIN and SIGTTOU */
static void suspend (int dont_care_sig)
{
(void)dont_care_sig;
/* reset terminal */
tcsetattr(STDIN_FILENO, TCSAFLUSH, &Savedtty);
printf("%s%s", tg2(0, Screen_rows), Cap_curs_norm);
......@@ -670,7 +672,7 @@ static int get_int (const char *prompt)
* SK_Kb (1) it's kilobytes
* SK_Mb (2) it's megabytes
* SK_Gb (3) it's gigabytes */
static char *scale_num (unsigned num, const int width, const unsigned type)
static const char *scale_num (unsigned num, const int width, const unsigned type)
{
/* kilobytes, megabytes, gigabytes, duh! */
static float scale[] = { 1024, 1024*1024, 1024*1024*1024, 0 };
......@@ -706,7 +708,7 @@ static char *scale_num (unsigned num, const int width, const unsigned type)
/*
* Do some scaling stuff.
* Format 'tics' to fit 'width' */
static char *scale_tics (TICS_t tics, const int width)
static const char *scale_tics (TICS_t tics, const int width)
{
#define T1 "%u:%02u.%02u"
#define T2 "%u:%02u"
......@@ -1587,6 +1589,7 @@ static void wins_reflag (int what, int flg)
* SIGWINCH and SIGCONT */
static void wins_resize (int dont_care_sig)
{
(void)dont_care_sig;
struct winsize wz;
WIN_t *w;
......@@ -2653,6 +2656,7 @@ static void so_lets_see_em (void)
*/
int main (int dont_care_argc, char **argv)
{
(void)dont_care_argc;
before(*argv);
/*
Ok, she's gone now. Don't you mind her, she means well but yes, she is
......
......@@ -57,7 +57,7 @@ static void usage(void) {
exit(EXIT_FAILURE);
}
static void crash(char *filename) {
static void crash(const char *filename) {
perror(filename);
exit(EXIT_FAILURE);
}
......
......@@ -218,7 +218,7 @@ static void showinfo(utmp_t *u, int formtype, int maxcmd, int from) {
fputs(" ", stdout);
if (best) {
if (best->cmdline)
print_strlist(stdout, best->cmdline, " ", maxcmd);
print_strlist(stdout, best->cmdline, maxcmd);
else
printf("%*.*s", -maxcmd, maxcmd, best->cmd);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment