1999-10-26 <tytso@valinux.com>
+ * fsck.c (wait_one): Fix gcc warnings; add #include for ctype.h,
+ add const to char * variables, and use NOARGS to declare
+ functions that take no arguments. Also fix a memory leak
+ in execute() where we weren't freeing argv[] after forking
+ the child process.
+
* chattr.c: Add hack to compile in a definition for S_ISLNK so we
can successfully compile even with warnings turned on.
#include <sys/stat.h>
#include <limits.h>
#include <stdio.h>
+#include <ctype.h>
#include <string.h>
#include <time.h>
#if HAVE_STDLIB_H
return;
}
-int parse_fstab_line(char *line, struct fs_info **ret_fs)
+static int parse_fstab_line(char *line, struct fs_info **ret_fs)
{
char *device, *mntpnt, *type, *opts, *freq, *passno, *cp;
struct fs_info *fs;
*ret_fs = 0;
strip_line(line);
- if (cp = strchr(line, '#'))
+ if ((cp = strchr(line, '#')))
*cp = 0; /* Ignore everything after the comment char */
cp = line;
/*
* Load the filesystem database from /etc/fstab
*/
-static void load_fs_info(char *filename)
+static void load_fs_info(const char *filename)
{
FILE *f;
char buf[1024];
return(s ? prog : NULL);
}
-static int progress_active()
+static int progress_active(NOARGS)
{
struct fsck_instance *inst;
* Execute a particular fsck program, and link it into the list of
* child processes we are waiting for.
*/
-static int execute(char *type, char *device, char *mntpt, int interactive)
+static int execute(const char *type, char *device, char *mntpt,
+ int interactive)
{
char *s, *argv[80], prog[80];
int argc, i;
if (progress & !progress_active()) {
if (strcmp(type, "ext2") == 0) {
- argv[argc++] = "-C0";
+ argv[argc++] = string_copy("-C0");
inst->flags |= FLAG_PROGRESS;
}
}
exit(EXIT_ERROR);
}
+ for (i=0; i < argc; i++)
+ free(argv[i]);
+
inst->pid = pid;
inst->prog = string_copy(prog);
inst->type = string_copy(type);
return(inst);
}
+ /*
+ * gcc -Wall fails saving throw against stupidity
+ * (inst and prev are thought to be uninitialized variables)
+ */
+ inst = prev = NULL;
+
do {
pid = wait(&status);
if (pid < 0) {
*/
static void fsck_device(char *device, int interactive)
{
- char *type = 0;
+ const char *type = 0;
struct fs_info *fsent;
int retval;
int status = 0;
int interactive = 0;
char *oldpath = getenv("PATH");
- char *fstab;
+ const char *fstab;
PRS(argc, argv);