Make sade(8) WARNS=3 clean.

This commit is contained in:
Xin LI 2006-08-08 13:45:46 +00:00
parent 1565bf54af
commit c7d9f7f033
14 changed files with 55 additions and 221 deletions

View File

@ -15,7 +15,6 @@ SRCS= command.c config.c devices.c \
# command.c
CFLAGS+= -DUSE_GZIP=1
.if ${MACHINE} == "pc98"
CFLAGS+= -DPC98
.endif

View File

@ -92,7 +92,7 @@ addit(char *key, int type, void *cmd, void *data)
/* Add a shell command under a given key */
void
command_shell_add(char *key, char *fmt, ...)
command_shell_add(char *key, const char *fmt, ...)
{
va_list args;
char *cmd;

View File

@ -174,7 +174,7 @@ configFstab(dialogMenuItem *self)
Device **devs;
Disk *disk;
FILE *fstab;
int i, cnt;
int i;
Chunk *c1, *c2;
if (file_readable("/etc/fstab"))

View File

@ -107,9 +107,6 @@ deviceTry(struct _devname dev, char *try, int i)
{
int fd;
char unit[80];
mode_t m;
dev_t d;
int fail;
snprintf(unit, sizeof unit, dev.name, i);
snprintf(try, FILENAME_MAX, "/dev/%s", unit);
@ -172,7 +169,7 @@ deviceReset(void)
void
deviceGetAll(void)
{
int i, j, fd, s;
int i, j, fd;
char **names;
msgNotify("Probing devices, please wait (this can take a while)...");
@ -200,7 +197,6 @@ deviceGetAll(void)
int i;
for (i = 0; names[i]; i++) {
Chunk *c1;
Disk *d;
/* Ignore memory disks */

View File

@ -69,41 +69,6 @@ typedef struct command_buffer_ {
char * string;
} command_buffer;
static void
dispatch_free_command(command_buffer *item)
{
REMQUE(item);
free(item->string);
free(item);
}
static void
dispatch_free_all(qelement *head)
{
command_buffer *item;
while (!EMPTYQUE(*head)) {
item = (command_buffer *) head->q_forw;
dispatch_free_command(item);
}
}
static command_buffer *
dispatch_add_command(qelement *head, char *string)
{
command_buffer *new;
new = malloc(sizeof(command_buffer));
if (!new)
return NULL;
new->string = strdup(string);
INSQUEUE(new, head->q_back);
return new;
}
/*
* Command processing
*/
@ -194,75 +159,3 @@ dispatchCommand(char *str)
return i;
}
/*
* File processing
*/
static qelement *
dispatch_load_fp(FILE *fp)
{
qelement *head;
char buf[BUFSIZ], *cp;
head = malloc(sizeof(qelement));
if (!head)
return NULL;
INITQUE(*head);
while (fgets(buf, sizeof buf, fp)) {
if ((cp = strchr(buf, '\n')) != NULL)
*cp = '\0';
if (*buf == '\0' || *buf == '#')
continue;
if (!dispatch_add_command(head, buf))
return NULL;
}
return head;
}
static int
dispatch_execute(qelement *head)
{
int result = DITEM_SUCCESS;
command_buffer *item;
char *old_interactive;
if (!head)
return result | DITEM_FAILURE;
old_interactive = variable_get(VAR_NONINTERACTIVE);
if (old_interactive)
old_interactive = strdup(old_interactive); /* save copy */
/* Hint to others that we're running from a script, should they care */
variable_set2(VAR_NONINTERACTIVE, "yes", 0);
while (!EMPTYQUE(*head)) {
item = (command_buffer *) head->q_forw;
if (DITEM_STATUS(dispatchCommand(item->string)) != DITEM_SUCCESS) {
msgConfirm("Command `%s' failed - rest of script aborted.\n",
item->string);
result |= DITEM_FAILURE;
break;
}
dispatch_free_command(item);
}
dispatch_free_all(head);
if (!old_interactive)
variable_unset(VAR_NONINTERACTIVE);
else {
variable_set2(VAR_NONINTERACTIVE, old_interactive, 0);
free(old_interactive);
}
return result;
}

View File

@ -240,7 +240,7 @@ dmenuVarsCheck(dialogMenuItem *item)
int
dmenuRadioCheck(dialogMenuItem *item)
{
return (*((unsigned int *)item->data) == item->aux);
return (*((long *)item->data) == item->aux);
}
static int

View File

@ -51,21 +51,12 @@
#include <unistd.h>
#include <termios.h>
static void create_termcap(void);
#define TERMCAP_FILE "/usr/share/misc/termcap"
static void installConfigure(void);
Boolean
checkLabels(Boolean whinge)
{
Device **devs;
Boolean status;
Disk *disk;
PartInfo *pi;
Chunk *c1, *c2;
int i;
/* Don't allow whinging if noWarn is set */
if (variable_get(VAR_NO_WARN))
@ -174,7 +165,7 @@ installFilesystems(dialogMenuItem *self)
if (c2 == RootChunk)
continue;
sprintf(dname, "%s/dev/%s", c2->name);
sprintf(dname, "/dev/%s", c2->name);
if (tmp->do_newfs && (!upgrade ||
!msgNoYes("You are upgrading - are you SURE you"
@ -182,13 +173,7 @@ installFilesystems(dialogMenuItem *self)
performNewfs(tmp, dname, QUEUE_YES);
else
command_shell_add(tmp->mountpoint,
"fsck_ffs -y %s/dev/%s", c2->name);
#if 0
if (tmp->soft)
command_shell_add(tmp->mountpoint,
"tunefs -n enable %s/dev/%s", RunningAsInit ?
"/mnt" : "", c2->name);
#endif
"fsck_ffs -y /dev/%s", c2->name);
command_func_add(tmp->mountpoint, Mount, c2->name);
}
else if (c2->type == part && c2->subtype == FS_SWAP) {
@ -197,7 +182,7 @@ installFilesystems(dialogMenuItem *self)
if (c2 == SwapChunk)
continue;
sprintf(fname, "%s/dev/%s", c2->name);
sprintf(fname, "/dev/%s", c2->name);
i = (Fake || swapon(fname));
if (!i) {
dialog_clear_norefresh();
@ -213,7 +198,7 @@ installFilesystems(dialogMenuItem *self)
(root->do_newfs || upgrade)) {
char name[FILENAME_MAX];
sprintf(name, "%s/%s", ((PartInfo *)c1->private_data)->mountpoint);
sprintf(name, "/%s", ((PartInfo *)c1->private_data)->mountpoint);
Mkdir(name);
}
#if defined(__ia64__)
@ -259,7 +244,6 @@ getRelname(void)
int
installVarDefaults(dialogMenuItem *self)
{
char *cp;
/* Set default startup options */
variable_set2(VAR_RELNAME, getRelname(), 0);

View File

@ -831,7 +831,7 @@ print_command_summary(void)
static void
clear_wins(void)
{
extern void print_label_chunks();
clear();
print_label_chunks();
}

View File

@ -35,13 +35,6 @@
const char *StartName; /* Initial contents of argv[0] */
static void
screech(int sig)
{
msgDebug("\007Signal %d caught! That's bad!\n", sig);
longjmp(BailOut, sig);
}
int
main(int argc, char **argv)
{

View File

@ -34,14 +34,6 @@ static const char rcsid[] =
#include "sade.h"
/* Miscellaneous work routines for menus */
static int
checkTrue(dialogMenuItem *item)
{
return TRUE;
}
/* All the system menus go here.
*
* Hardcoded things like version number strings will disappear from
@ -61,7 +53,7 @@ DMenu MenuDiskDevices = {
"Use [TAB] to get to the buttons and leave this menu.",
"Press F1 for important information regarding disk geometry!",
"drives",
{ { NULL } },
{ { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 } },
};
DMenu MenuMain = {
@ -71,9 +63,10 @@ DMenu MenuMain = {
"DISKUTIL",
"main",
{
{ "1 Partition", "Managing disk partitions", NULL, diskPartitionEditor },
{ "2 Label", "Label allocated disk partitions", NULL, diskLabelEditor },
{ NULL } },
{ "1 Partition", "Managing disk partitions", NULL, diskPartitionEditor, NULL, NULL, 0, 0, 0, 0 },
{ "2 Label", "Label allocated disk partitions", NULL, diskLabelEditor, NULL, NULL, 0, 0, 0, 0 },
{ NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 }
},
};
#if defined(__i386__) || defined(__amd64__)
@ -90,7 +83,7 @@ DMenu MenuIPLType = {
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr },
{ "None", "Leave the IPL untouched",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
{ NULL } },
{ NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 } },
};
#else
/* MBR type menu */
@ -109,12 +102,12 @@ DMenu MenuMBRType = {
"Press F1 to read about drive setup",
"drives",
{ { "BootMgr", "Install the FreeBSD Boot Manager",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr },
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, 0, 0, 0, 0 },
{ "Standard", "Install a standard MBR (no boot manager)",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
{ "None", "Leave the Master Boot Record untouched",
dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 },
{ NULL } },
{ NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0 } },
};
#endif /* PC98 */
#endif /* __i386__ */

View File

@ -44,7 +44,7 @@ isDebug(void)
/* Whack up an informational message on the status line, in stand-out */
void
msgYap(char *fmt, ...)
msgYap(const char *fmt, ...)
{
va_list args;
char *errstr;
@ -63,7 +63,7 @@ msgYap(char *fmt, ...)
/* Whack up an informational message on the status line */
void
msgInfo(char *fmt, ...)
msgInfo(const char *fmt, ...)
{
va_list args;
char *errstr;
@ -98,7 +98,7 @@ msgInfo(char *fmt, ...)
/* Whack up a warning on the status line */
void
msgWarn(char *fmt, ...)
msgWarn(const char *fmt, ...)
{
va_list args;
char *errstr;
@ -121,7 +121,7 @@ msgWarn(char *fmt, ...)
/* Whack up an error on the status line */
void
msgError(char *fmt, ...)
msgError(const char *fmt, ...)
{
va_list args;
char *errstr;
@ -144,7 +144,7 @@ msgError(char *fmt, ...)
/* Whack up a fatal error on the status line */
void
msgFatal(char *fmt, ...)
msgFatal(const char *fmt, ...)
{
va_list args;
char *errstr;
@ -174,7 +174,7 @@ msgFatal(char *fmt, ...)
/* Put up a message in a popup confirmation box */
void
msgConfirm(char *fmt, ...)
msgConfirm(const char *fmt, ...)
{
va_list args;
char *errstr;
@ -196,7 +196,7 @@ msgConfirm(char *fmt, ...)
/* Put up a message in a popup information box */
void
msgNotify(char *fmt, ...)
msgNotify(const char *fmt, ...)
{
va_list args;
char *errstr;
@ -214,7 +214,7 @@ msgNotify(char *fmt, ...)
/* Put up a message in a popup yes/no box and return 0 for YES, 1 for NO */
int
msgYesNo(char *fmt, ...)
msgYesNo(const char *fmt, ...)
{
va_list args;
char *errstr;
@ -240,7 +240,7 @@ msgYesNo(char *fmt, ...)
/* Put up a message in a popup no/yes box and return 0 for YES, 1 for NO */
int
msgNoYes(char *fmt, ...)
msgNoYes(const char *fmt, ...)
{
va_list args;
char *errstr;
@ -266,7 +266,7 @@ msgNoYes(char *fmt, ...)
/* Put up a message in an input box and return the value */
char *
msgGetInput(char *buf, char *fmt, ...)
msgGetInput(char *buf, const char *fmt, ...)
{
va_list args;
char *errstr;
@ -298,7 +298,7 @@ msgGetInput(char *buf, char *fmt, ...)
/* Write something to the debugging port */
void
msgDebug(char *fmt, ...)
msgDebug(const char *fmt, ...)
{
va_list args;
char *dbg;
@ -315,7 +315,7 @@ msgDebug(char *fmt, ...)
/* Tell the user there's some output to go look at */
void
msgWeHaveOutput(char *fmt, ...)
msgWeHaveOutput(const char *fmt, ...)
{
va_list args;
char *errstr;
@ -336,14 +336,14 @@ msgWeHaveOutput(char *fmt, ...)
/* Simple versions of msgConfirm() and msgNotify() for calling from scripts */
int
msgSimpleConfirm(char *str)
msgSimpleConfirm(const char *str)
{
msgConfirm("%s", str);
return DITEM_SUCCESS;
}
int
msgSimpleNotify(char *str)
msgSimpleNotify(const char *str)
{
msgNotify("%s", str);
return DITEM_SUCCESS;

View File

@ -146,13 +146,7 @@ typedef struct _dmenu {
char *prompt; /* Our prompt */
char *helpline; /* Line of help at bottom */
char *helpfile; /* Help file for "F1" */
#if (__STDC_VERSION__ >= 199901L) || (__GNUC__ >= 3)
dialogMenuItem items[]; /* Array of menu items */
#elif __GNUC__
dialogMenuItem items[0]; /* Array of menu items */
#else
#error "Create hack for C89 and K&R compilers."
#endif
} DMenu;
/* An rc.conf variable */
@ -255,7 +249,7 @@ typedef struct _opt {
enum { OPT_IS_STRING, OPT_IS_INT, OPT_IS_FUNC, OPT_IS_VAR } type;
void *data;
void *aux;
char *(*check)();
char *(*check)(void);
} Option;
typedef int (*commandFunc)(char *key, void *data);
@ -307,7 +301,7 @@ extern void display_helpline(WINDOW *w, int y, int width);
extern void command_clear(void);
extern void command_sort(void);
extern void command_execute(void);
extern void command_shell_add(char *key, char *fmt, ...) __printflike(2, 3);
extern void command_shell_add(char *key, const char *fmt, ...) __printflike(2, 3);
extern void command_func_add(char *key, commandFunc func, void *data);
/* config.c */
@ -327,7 +321,7 @@ extern Device **deviceFind(char *name, DeviceType type);
extern Device **deviceFindDescr(char *name, char *desc, DeviceType class);
extern int deviceCount(Device **devs);
extern Device *new_device(char *name);
extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
extern Device *deviceRegister(char *name, char *desc, char *devicename, DeviceType type, Boolean enabled,
Boolean (*init)(Device *mediadev),
FILE * (*get)(Device *dev, char *file, Boolean probe),
void (*shutDown)(Device *mediadev),
@ -363,7 +357,7 @@ extern int dmenuSetVariables(dialogMenuItem *tmp);
extern int dmenuToggleVariable(dialogMenuItem *tmp);
extern int dmenuSetFlag(dialogMenuItem *tmp);
extern int dmenuSetValue(dialogMenuItem *tmp);
extern Boolean dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons);
extern Boolean dmenuOpen(DMenu *menu, int *choice, int *bscroll, int *curr, int *max, Boolean buttons);
extern Boolean dmenuOpenSimple(DMenu *menu, Boolean buttons);
extern int dmenuVarCheck(dialogMenuItem *item);
extern int dmenuVarsCheck(dialogMenuItem *item);
@ -439,7 +433,7 @@ extern void items_free(dialogMenuItem *list, int *curr, int *max);
extern int Mkdir(char *);
extern int Mkdir_command(char *key, void *data);
extern int Mount(char *, void *data);
extern int Mount_msdosfs(char *mountp, void *devname);
extern int Mount_msdosfs(char *mountp, void *devicename);
extern WINDOW *openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height);
extern ComposeObj *initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max);
extern int layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj,
@ -451,20 +445,20 @@ extern char *sstrncpy(char *dst, const char *src, int size);
/* msg.c */
extern Boolean isDebug(void);
extern void msgInfo(char *fmt, ...) __printf0like(1, 2);
extern void msgYap(char *fmt, ...) __printflike(1, 2);
extern void msgWarn(char *fmt, ...) __printflike(1, 2);
extern void msgDebug(char *fmt, ...) __printflike(1, 2);
extern void msgError(char *fmt, ...) __printflike(1, 2);
extern void msgFatal(char *fmt, ...) __printflike(1, 2);
extern void msgConfirm(char *fmt, ...) __printflike(1, 2);
extern void msgNotify(char *fmt, ...) __printflike(1, 2);
extern void msgWeHaveOutput(char *fmt, ...) __printflike(1, 2);
extern int msgYesNo(char *fmt, ...) __printflike(1, 2);
extern int msgNoYes(char *fmt, ...) __printflike(1, 2);
extern char *msgGetInput(char *buf, char *fmt, ...) __printflike(2, 3);
extern int msgSimpleConfirm(char *);
extern int msgSimpleNotify(char *);
extern void msgInfo(const char *fmt, ...) __printf0like(1, 2);
extern void msgYap(const char *fmt, ...) __printflike(1, 2);
extern void msgWarn(const char *fmt, ...) __printflike(1, 2);
extern void msgDebug(const char *fmt, ...) __printflike(1, 2);
extern void msgError(const char *fmt, ...) __printflike(1, 2);
extern void msgFatal(const char *fmt, ...) __printflike(1, 2);
extern void msgConfirm(const char *fmt, ...) __printflike(1, 2);
extern void msgNotify(const char *fmt, ...) __printflike(1, 2);
extern void msgWeHaveOutput(const char *fmt, ...) __printflike(1, 2);
extern int msgYesNo(const char *fmt, ...) __printflike(1, 2);
extern int msgNoYes(const char *fmt, ...) __printflike(1, 2);
extern char *msgGetInput(char *buf, const char *fmt, ...) __printflike(2, 3);
extern int msgSimpleConfirm(const char *);
extern int msgSimpleNotify(const char *);
/* pccard.c */
extern void pccardInitialize(void);
@ -482,7 +476,7 @@ extern void systemChangeFont(const u_char font[]);
extern void systemChangeLang(char *lang);
extern void systemChangeTerminal(char *color, const u_char c_termcap[], char *mono, const u_char m_termcap[]);
extern void systemChangeScreenmap(const u_char newmap[]);
extern int vsystem(char *fmt, ...) __printflike(1, 2);
extern int vsystem(const char *fmt, ...) __printflike(1, 2);
/* termcap.c */
extern int set_termcap(void);
@ -511,11 +505,5 @@ extern void slice_wizard(Disk *d);
#define DEVICE_GET(d, b, f) ((d) != NULL ? (d)->get((d), (b), (f)) : NULL)
#define DEVICE_SHUTDOWN(d) ((d) != NULL ? (d)->shutdown((d)) : (void)0)
#ifdef USE_GZIP
#define UNZIPPER "gunzip"
#else
#define UNZIPPER "bunzip2"
#endif
#endif
/* _SYSINSTALL_H_INCLUDE */

View File

@ -29,8 +29,6 @@
#define DOC_TMP_DIR "/tmp/.doc"
#define DOC_TMP_FILE "/tmp/.doc/doc.tmp"
static pid_t ehs_pid;
/*
* Handle interrupt signals - this probably won't work in all cases
* due to our having bogotified the internal state of dialog or curses,
@ -58,8 +56,8 @@ intr_restart(dialogMenuItem *self)
}
static dialogMenuItem intrmenu[] = {
{ "Restart", "Restart the program", NULL, intr_restart },
{ "Continue", "Continue without restarting", NULL, intr_continue },
{ "Restart", "Restart the program", NULL, intr_restart, NULL, NULL, 0, 0, 0, 0 },
{ "Continue", "Continue without restarting", NULL, intr_continue, NULL, NULL, 0, 0, 0, 0 },
};
@ -116,8 +114,6 @@ systemInitialize(int argc, char **argv)
(i == sizeof(boothowto)) && (boothowto & RB_VERBOSE))
variable_set2(VAR_DEBUG, "YES", 0);
char hname[256];
if (set_termcap() == -1) {
printf("Can't find terminal entry\n");
exit(-1);
@ -274,7 +270,7 @@ systemChangeTerminal(char *color, const u_char c_term[],
}
int
vsystem(char *fmt, ...)
vsystem(const char *fmt, ...)
{
va_list args;
int pstat;

View File

@ -26,15 +26,7 @@
static void
prompt_term(char **termp, char **termcapp)
{
char str[80];
static struct {
const char *term, *termcap;
} lookup[] = { { "ansi", termcap_ansi },
{ "vt100", termcap_vt100 },
{ "cons25", termcap_cons25 },
{ "cons25-m", termcap_cons25_m },
{ "xterm", termcap_xterm },
{ "cons25w", termcap_cons25w } }; /* must be last */
char str[80];
printf("\nPlease set your TERM variable before running this program.\n");
printf("Defaulting to an ANSI compatible terminal - please press RETURN\n");