summaryrefslogtreecommitdiff
path: root/sysctl.c
diff options
context:
space:
mode:
authoralbert <>2002-11-25 23:24:40 +0000
committeralbert <>2002-11-25 23:24:40 +0000
commit1572abd03edcc3f278586b9075a364cf0643ce5d (patch)
treecb8094d8c520cb8f2f7ffdcb195555c06c3fee7f /sysctl.c
parent3f6928c4fb21f1605e8b807384802032f45b5a85 (diff)
downloadprocps-ng-1572abd03edcc3f278586b9075a364cf0643ce5d.tar.gz
part 1
Diffstat (limited to 'sysctl.c')
-rw-r--r--sysctl.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/sysctl.c b/sysctl.c
index 911ff7a..946bc3b 100644
--- a/sysctl.c
+++ b/sysctl.c
@@ -58,7 +58,7 @@ static const char ERR_PRELOAD_FILE[] = "error: unable to open preload file '%s'\
static const char WARN_BAD_LINE[] = "warning: %s(%d): invalid syntax, continuing...\n";
-static void slashdot(char *p, char old, char new){
+static void slashdot(char *restrict p, char old, char new){
p = strpbrk(p,"/.");
if(!p) return; /* nothing -- can't be, but oh well */
if(*p==new) return; /* already in desired format */
@@ -76,7 +76,7 @@ static void slashdot(char *p, char old, char new){
* Display the usage format
*
*/
-static int Usage(const char *name) {
+static int Usage(const char *restrict const name) {
printf("usage: %s [-n] variable ... \n"
" %s [-n] -w variable=value ... \n"
" %s [-n] -a \n"
@@ -116,16 +116,17 @@ static char *StripLeadingAndTrailingSpaces(char *oneline) {
* Read a sysctl setting
*
*/
-static int ReadSetting(const char *setting) {
+static int ReadSetting(const char *restrict const name) {
int rc = 0;
- char *tmpname, *outname;
+ char *restrict tmpname;
+ char *restrict outname;
char inbuf[1025];
- const char *name = setting;
- FILE *fp;
+ FILE *restrict fp;
- if (!setting || !*setting) {
- fprintf(stderr, ERR_INVALID_KEY, setting);
- } /* endif */
+ if (!name || !*name) {
+ fprintf(stderr, ERR_INVALID_KEY, name);
+ return -1;
+ }
/* used to open the file */
tmpname = malloc(strlen(name)+strlen(PROC_PATH)+1);
@@ -179,12 +180,12 @@ static int ReadSetting(const char *setting) {
* Display all the sysctl settings
*
*/
-static int DisplayAll(const char *path, bool ShowTableUtil) {
+static int DisplayAll(const char *restrict const path, bool ShowTableUtil) {
int rc = 0;
int rc2;
- DIR *dp;
- struct dirent *de;
- char *tmpdir;
+ DIR *restrict dp;
+ struct dirent *restrict de;
+ char *restrict tmpdir;
struct stat ts;
dp = opendir(path);
@@ -195,7 +196,7 @@ static int DisplayAll(const char *path, bool ShowTableUtil) {
} else {
readdir(dp); readdir(dp); /* skip . and .. */
while (( de = readdir(dp) )) {
- tmpdir = (char *)malloc(strlen(path)+strlen(de->d_name)+2);
+ tmpdir = (char *restrict)malloc(strlen(path)+strlen(de->d_name)+2);
sprintf(tmpdir, "%s%s", path, de->d_name);
rc2 = stat(tmpdir, &ts); /* should check this return code */
if (rc2 != 0) {
@@ -206,15 +207,14 @@ static int DisplayAll(const char *path, bool ShowTableUtil) {
DisplayAll(tmpdir, ShowTableUtil);
} else {
rc |= ReadSetting(tmpdir+strlen(PROC_PATH));
- } /* endif */
- } /* endif */
+ }
+ }
free(tmpdir);
- } /* end while */
+ }
closedir(dp);
- } /* endif */
-
+ }
return rc;
-} /* end DisplayAll() */
+}
/*
@@ -302,7 +302,7 @@ static int WriteSetting(const char *setting) {
* - we parse the file and then reform it (strip out whitespace)
*
*/
-static void Preload(const char *filename) {
+static void Preload(const char *restrict const filename) {
FILE *fp;
char oneline[257];
char buffer[257];