Fix numerous warnings. Aside from menu items in system.c and menu.c

this now compiles on i386 with WARNS?= 3.  Most of the fixes included
adding missing 'static' keywords to internal functions, using fully-defined
terminators in statically defined arrays of structs, and various
signed vs unsigned mismatches.  Also G/C'd unused configSecurity()
function.
This commit is contained in:
jhb 2006-02-28 21:49:33 +00:00
parent 6dd5abcf92
commit 1ec49d602a
24 changed files with 59 additions and 72 deletions

View File

@ -96,7 +96,7 @@ keymap.h:
echo -n ' { "'$$map'", ' >> keymap.tmp ; \
echo "&keymap_$$map }," | tr '[-.]' '_' >> keymap.tmp ; \
done
( echo " { 0 }"; echo "};" ; echo "" ) >> keymap.tmp
( echo " { NULL, NULL }"; echo "};" ; echo "" ) >> keymap.tmp
mv keymap.tmp keymap.h
countries.h: ${.CURDIR}/../../share/misc/iso3166

View File

@ -268,7 +268,7 @@ configFstab(dialogMenuItem *self)
* returns number of lines read. line contents
* are malloc'd and must be freed by the caller.
*/
int
static int
readConfig(char *config, char **lines, int max)
{
FILE *fp;
@ -605,17 +605,6 @@ configSecurelevelNetworkSecure(dialogMenuItem *self)
return DITEM_SUCCESS;
}
int
configSecurity(dialogMenuItem *self)
{
WINDOW *w = savescr();
dialog_clear_norefresh();
dmenuOpenSimple(&MenuSecurity, FALSE);
restorescr(w);
return DITEM_SUCCESS;
}
int
configResolv(dialogMenuItem *ditem)
{

View File

@ -180,7 +180,7 @@ print_chunks(Disk *d, int u)
}
static void
print_command_summary()
print_command_summary(void)
{
mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
mvprintw(16, 0, "A = Use Entire Disk G = set Drive Geometry C = Create Slice F = `DD' mode");

View File

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

View File

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

View File

@ -268,6 +268,9 @@ typedef struct _layout {
void *obj; /* The obj pointer returned by libdialog */
} Layout;
/* Layout array terminator. */
#define LAYOUT_END { 0, 0, 0, 0, NULL, NULL, NULL, 0, NULL }
typedef enum {
DEVICE_TYPE_NONE,
DEVICE_TYPE_DISK,
@ -355,7 +358,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)(struct _opt *);
} Option;
/* Weird index nodey things we use for keeping track of package information */

View File

@ -15,7 +15,7 @@
#include <err.h>
#include <libdisk.h>
int
static int
scan_block(int fd, daddr_t block)
{
u_char foo[512];
@ -27,7 +27,7 @@ scan_block(int fd, daddr_t block)
return 0;
}
void
static void
Scan_Disk(Disk *d)
{
char device[64];

View File

@ -96,7 +96,7 @@ keymap.h:
echo -n ' { "'$$map'", ' >> keymap.tmp ; \
echo "&keymap_$$map }," | tr '[-.]' '_' >> keymap.tmp ; \
done
( echo " { 0 }"; echo "};" ; echo "" ) >> keymap.tmp
( echo " { NULL, NULL }"; echo "};" ; echo "" ) >> keymap.tmp
mv keymap.tmp keymap.h
countries.h: ${.CURDIR}/../../share/misc/iso3166

View File

@ -115,7 +115,7 @@ static Layout layout[] = {
{ 19, 35, 0, 0,
"CANCEL", "Select this if you wish to cancel this screen",
&cancelbutton, BUTTONOBJ, NULL },
{ 0 },
LAYOUT_END,
};
static int

View File

@ -268,7 +268,7 @@ configFstab(dialogMenuItem *self)
* returns number of lines read. line contents
* are malloc'd and must be freed by the caller.
*/
int
static int
readConfig(char *config, char **lines, int max)
{
FILE *fp;
@ -605,17 +605,6 @@ configSecurelevelNetworkSecure(dialogMenuItem *self)
return DITEM_SUCCESS;
}
int
configSecurity(dialogMenuItem *self)
{
WINDOW *w = savescr();
dialog_clear_norefresh();
dmenuOpenSimple(&MenuSecurity, FALSE);
restorescr(w);
return DITEM_SUCCESS;
}
int
configResolv(dialogMenuItem *ditem)
{

View File

@ -180,7 +180,7 @@ print_chunks(Disk *d, int u)
}
static void
print_command_summary()
print_command_summary(void)
{
mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
mvprintw(16, 0, "A = Use Entire Disk G = set Drive Geometry C = Create Slice F = `DD' mode");

View File

@ -68,6 +68,7 @@ static Distribution XOrgDistTable[];
{ name, mask, DIST_ ## flag, DT_PACKAGE, { package } }
#define DTE_SUBDIST(name, mask, flag, subdist) \
{ name, mask, DIST_ ## flag, DT_SUBDIST, { .my_dist = subdist } }
#define DTE_END { NULL, NULL, 0, 0, { NULL } }
#define BASE_DIST (&DistTable[0])
@ -88,7 +89,7 @@ static Distribution DistTable[] = {
DTE_TARBALL("ports", &Dists, PORTS, "/usr"),
DTE_TARBALL("local", &Dists, LOCAL, "/"),
DTE_SUBDIST("X.Org", &Dists, XORG, XOrgDistTable),
{ NULL },
DTE_END,
};
/* The /usr/src distribution */
@ -113,7 +114,7 @@ static Distribution SrcDistTable[] = {
DTE_TARBALL("susbin", &SrcDists, SRC_USBIN, "/usr/src"),
DTE_TARBALL("stools", &SrcDists, SRC_TOOLS, "/usr/src"),
DTE_TARBALL("srescue", &SrcDists, SRC_RESCUE, "/usr/src"),
{ NULL },
DTE_END,
};
/* The X.Org distribution */
@ -136,7 +137,7 @@ static Distribution XOrgDistTable[] = {
DTE_PACKAGE("Xft1", &XOrgDists, XORG_FONTS_T1, "xorg-fonts-type1"),
DTE_PACKAGE("Xftt", &XOrgDists, XORG_FONTS_TT, "xorg-fonts-truetype"),
DTE_PACKAGE("Xfs", &XOrgDists, XORG_FONTSERVER, "xorg-fontserver"),
{ NULL },
DTE_END,
};
static int distMaybeSetPorts(dialogMenuItem *self);

View File

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

View File

@ -36,7 +36,7 @@
extern const char *ftp_dirs[]; /* defined in ftp.c */
Boolean
static Boolean
checkAccess(Boolean proxyCheckOnly)
{
/*

View File

@ -60,7 +60,7 @@ static void index_recorddeps(Boolean add, PkgNodePtr root, IndexEntryPtr ie);
PkgNode Top, Plist;
/* Smarter strdup */
inline char *
static inline char *
_strdup(char *ptr)
{
return ptr ? strdup(ptr) : NULL;
@ -289,7 +289,7 @@ readline(FILE *fp, char *buf, int max)
* lines without a set number of '|' delimited fields.
*/
int
static int
index_parse(FILE *fp, char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint, char *cats, char *rdeps, int *volume)
{
char line[10240 + 2048 * 7];
@ -437,7 +437,7 @@ index_sort(PkgNodePtr top)
}
/* Delete an entry out of the list it's in (only the plist, at present) */
void
static void
index_delete(PkgNodePtr n)
{
if (n->next) {
@ -482,7 +482,7 @@ index_search(PkgNodePtr top, char *str, PkgNodePtr *tp)
return p;
}
int
static int
pkg_checked(dialogMenuItem *self)
{
ListPtrsPtr lists = (ListPtrsPtr)self->aux;
@ -502,7 +502,7 @@ pkg_checked(dialogMenuItem *self)
return FALSE;
}
int
static int
pkg_fire(dialogMenuItem *self)
{
int ret;
@ -561,7 +561,7 @@ pkg_fire(dialogMenuItem *self)
return ret;
}
void
static void
pkg_selected(dialogMenuItem *self, int is_selected)
{
PkgNodePtr kp = self->data;
@ -575,7 +575,8 @@ int
index_menu(PkgNodePtr root, PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll)
{
struct ListPtrs lists;
int n, rval, maxname;
size_t maxname;
int n, rval;
int curr, max;
PkgNodePtr kp;
dialogMenuItem *nitems;
@ -592,7 +593,7 @@ index_menu(PkgNodePtr root, PkgNodePtr top, PkgNodePtr plist, int *pos, int *scr
/* Figure out if this menu is full of "leaves" or "branches" */
for (kp = top->kids; kp && kp->name; kp = kp->next) {
int len;
size_t len;
++n;
if (kp->type == PACKAGE && plist) {

View File

@ -122,10 +122,10 @@ static HitList etc_files [] = {
{ JUST_COPY, "syslog.conf", TRUE, NULL },
{ JUST_COPY, "ttys", TRUE, NULL },
{ JUST_COPY, "uucp", TRUE, NULL },
{ 0 },
{ 0, NULL, FALSE, NULL },
};
void
static void
traverseHitlist(HitList *h)
{
system("rm -rf /etc/upgrade");

View File

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

View File

@ -325,7 +325,8 @@ mediaSetFTP(dialogMenuItem *self)
static Device ftpDevice;
char *cp, hbuf[MAXHOSTNAMELEN], *hostname, *dir;
struct addrinfo hints, *res;
int af, urllen;
int af;
size_t urllen;
extern int FtpPort;
static Device *networkDev = NULL;
@ -554,7 +555,7 @@ mediaSetNFS(dialogMenuItem *self)
static Device *networkDev = NULL;
char *cp, *idx;
char hostname[MAXPATHLEN];
int pathlen;
size_t pathlen;
mediaClose();
cp = variable_get_value(VAR_NFS_PATH, "Please enter the full NFS file specification for the remote\n"

View File

@ -42,12 +42,12 @@
int fixitTtyWhich(dialogMenuItem *);
static char *
varCheck(Option opt)
varCheck(Option *opt)
{
char *cp = NULL;
if (opt.aux)
cp = variable_get((char *)opt.aux);
if (opt->aux)
cp = variable_get((char *)opt->aux);
if (!cp)
return "NO";
return cp;
@ -55,13 +55,13 @@ varCheck(Option opt)
/* Show our little logo */
static char *
resetLogo(char *str)
resetLogo(Option *opt)
{
return "[RESET!]";
}
static char *
mediaCheck(Option opt)
mediaCheck(Option *opt)
{
if (mediaDevice) {
switch(mediaDevice->type) {
@ -155,10 +155,10 @@ static Option Options[] = {
{ "Fixit Console", "Which tty to use for the Fixit action.",
OPT_IS_FUNC, fixitTtyWhich, VAR_FIXIT_TTY, varCheck },
{ "Re-scan Devices", "Re-run sysinstall's initial device probe",
OPT_IS_FUNC, deviceRescan },
OPT_IS_FUNC, deviceRescan, NULL, NULL },
{ "Use Defaults", "Reset all values to startup defaults",
OPT_IS_FUNC, installVarDefaults, 0, resetLogo },
{ NULL },
OPT_IS_FUNC, installVarDefaults, NULL, resetLogo },
{ NULL, NULL, 0, NULL, NULL, NULL },
};
#define OPT_START_ROW 4
@ -183,7 +183,7 @@ value_of(Option opt)
case OPT_IS_FUNC:
case OPT_IS_VAR:
if (opt.check)
return opt.check(opt);
return opt.check(&opt);
else
return "<*>";
}
@ -216,7 +216,7 @@ fire(Option opt)
variable_set2(opt.aux, "YES", 0);
}
if (opt.check)
opt.check(opt);
opt.check(&opt);
refresh();
return status;
}

View File

@ -115,7 +115,8 @@ package_extract(Device *dev, char *name, Boolean depended)
{
char path[MAXPATHLEN];
const char *PkgExts[] = { "", ".tbz", ".tbz2", ".tgz" };
int ext, last_msg, pathend, ret;
int last_msg, pathend, ret;
size_t ext;
FILE *fp;
last_msg = 0;

View File

@ -268,6 +268,9 @@ typedef struct _layout {
void *obj; /* The obj pointer returned by libdialog */
} Layout;
/* Layout array terminator. */
#define LAYOUT_END { 0, 0, 0, 0, NULL, NULL, NULL, 0, NULL }
typedef enum {
DEVICE_TYPE_NONE,
DEVICE_TYPE_DISK,
@ -355,7 +358,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)(struct _opt *);
} Option;
/* Weird index nodey things we use for keeping track of package information */

View File

@ -104,7 +104,7 @@ static Layout layout[] = {
{ 19, 35, 0, 0,
"CANCEL", "Select this if you wish to cancel this screen",
&cancelbutton, BUTTONOBJ, NULL },
{ 0 },
LAYOUT_END,
};
#define _validByte(b) ((b) >= 0 && (b) <= 255)
@ -177,7 +177,7 @@ static int
verifyNetmask(const char *netmask, unsigned long *out)
{
unsigned long mask;
unsigned long tmp;
long tmp;
char *endptr;
if (netmask[0] == '0' && (netmask[1] == 'x' || netmask[1] == 'X')) {
@ -187,9 +187,10 @@ verifyNetmask(const char *netmask, unsigned long *out)
return 0;
} else {
/* Parse out quad decimal mask */
mask = strtoul(netmask, &endptr, 10);
if (!_validByte(mask) || *endptr++ != '.')
tmp = strtoul(netmask, &endptr, 10);
if (!_validByte(tmp) || *endptr++ != '.')
return 0;
mask = tmp;
tmp = strtoul(endptr, &endptr, 10);
if (!_validByte(tmp) || *endptr++ != '.')
return 0;

View File

@ -102,7 +102,7 @@ static Layout groupLayout[] = {
{ 18, 35, 0, 0,
"CANCEL", "Select this if you wish to cancel this screen",
&cancelbutton, BUTTONOBJ, NULL },
{ 0 },
LAYOUT_END,
};
/* The user configuration menu. */
@ -147,7 +147,7 @@ static Layout userLayout[] = {
{ 18, 35, 0, 0,
"CANCEL", "Select this if you wish to cancel this screen",
&cancelbutton, BUTTONOBJ, NULL },
{ 0 },
LAYOUT_END,
};
/* whine */

View File

@ -15,7 +15,7 @@
#include <err.h>
#include <libdisk.h>
int
static int
scan_block(int fd, daddr_t block)
{
u_char foo[512];
@ -27,7 +27,7 @@ scan_block(int fd, daddr_t block)
return 0;
}
void
static void
Scan_Disk(Disk *d)
{
char device[64];