summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.housekeeping2
-rw-r--r--src/drivers/net/3c595.c2
-rw-r--r--src/drivers/net/forcedeth.c2
-rw-r--r--src/drivers/net/via-rhine.c2
-rw-r--r--src/include/gpxe/xfer.h4
-rw-r--r--src/net/tcp/ftp.c61
6 files changed, 47 insertions, 26 deletions
diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
index ae0bae85..14d07fb0 100644
--- a/src/Makefile.housekeeping
+++ b/src/Makefile.housekeeping
@@ -265,7 +265,7 @@ ifdef BIN
#
CFLAGS += -I include -I arch/$(ARCH)/include -I .
CFLAGS += -Os -ffreestanding
-CFLAGS += -Wall -W
+CFLAGS += -Wall -W -Wformat-nonliteral
CFLAGS += -g
CFLAGS += $(EXTRA_CFLAGS)
ASFLAGS += $(EXTRA_ASFLAGS)
diff --git a/src/drivers/net/3c595.c b/src/drivers/net/3c595.c
index 7138f936..198e12e7 100644
--- a/src/drivers/net/3c595.c
+++ b/src/drivers/net/3c595.c
@@ -363,7 +363,7 @@ vxgetlink(void)
if (n > 0) {
printf("/");
}
- printf(conn_tab[k].name);
+ printf("%s", conn_tab[k].name );
n++;
}
}
diff --git a/src/drivers/net/forcedeth.c b/src/drivers/net/forcedeth.c
index 54fadbd7..a30f1378 100644
--- a/src/drivers/net/forcedeth.c
+++ b/src/drivers/net/forcedeth.c
@@ -452,7 +452,7 @@ static int reg_delay(int offset, u32 mask,
delaymax -= delay;
if (delaymax < 0) {
if (msg)
- printf(msg);
+ printf("%s", msg);
return 1;
}
} while ((readl(base + offset) & mask) != target);
diff --git a/src/drivers/net/via-rhine.c b/src/drivers/net/via-rhine.c
index fb43a924..bceaec66 100644
--- a/src/drivers/net/via-rhine.c
+++ b/src/drivers/net/via-rhine.c
@@ -1008,7 +1008,7 @@ rhine_probe1 (struct nic *nic, struct pci_device *pci, int ioaddr, int chip_id,
unsigned char mode3_reg;
if (rhine_debug > 0 && did_version++ == 0)
- printf (version);
+ printf ("%s",version);
// get revision id.
pci_read_config_byte(pci, PCI_REVISION, &revision_id);
diff --git a/src/include/gpxe/xfer.h b/src/include/gpxe/xfer.h
index 9575bf69..e592fa38 100644
--- a/src/include/gpxe/xfer.h
+++ b/src/include/gpxe/xfer.h
@@ -149,8 +149,8 @@ extern int xfer_deliver_raw ( struct xfer_interface *xfer,
const void *data, size_t len );
extern int xfer_vprintf ( struct xfer_interface *xfer,
const char *format, va_list args );
-extern int xfer_printf ( struct xfer_interface *xfer,
- const char *format, ... );
+extern int __attribute__ (( format ( printf, 2, 3 ) ))
+xfer_printf ( struct xfer_interface *xfer, const char *format, ... );
extern int xfer_seek ( struct xfer_interface *xfer, off_t offset, int whence );
extern void ignore_xfer_close ( struct xfer_interface *xfer, int rc );
diff --git a/src/net/tcp/ftp.c b/src/net/tcp/ftp.c
index 3b88f7b6..82dc19ca 100644
--- a/src/net/tcp/ftp.c
+++ b/src/net/tcp/ftp.c
@@ -109,23 +109,39 @@ static void ftp_done ( struct ftp_request *ftp, int rc ) {
*
*/
+/** An FTP control channel string */
+struct ftp_control_string {
+ /** Literal portion */
+ const char *literal;
+ /** Variable portion
+ *
+ * @v ftp FTP request
+ * @ret string Variable portion of string
+ */
+ const char * ( *variable ) ( struct ftp_request *ftp );
+};
+
/**
- * FTP control channel strings
+ * Retrieve FTP pathname
*
- * These are used as printf() format strings. Since only one of them
- * (RETR) takes an argument, we always supply that argument to the
- * snprintf() call.
+ * @v ftp FTP request
+ * @ret path FTP pathname
*/
-static const char * ftp_strings[] = {
- [FTP_CONNECT] = NULL,
- [FTP_USER] = "USER anonymous\r\n",
- [FTP_PASS] = "PASS etherboot@etherboot.org\r\n",
- [FTP_TYPE] = "TYPE I\r\n",
- [FTP_PASV] = "PASV\r\n",
- [FTP_RETR] = "RETR %s\r\n",
- [FTP_WAIT] = NULL,
- [FTP_QUIT] = "QUIT\r\n",
- [FTP_DONE] = NULL,
+static const char * ftp_uri_path ( struct ftp_request *ftp ) {
+ return ftp->uri->path;
+}
+
+/** FTP control channel strings */
+static struct ftp_control_string ftp_strings[] = {
+ [FTP_CONNECT] = { NULL, NULL },
+ [FTP_USER] = { "USER anonymous", NULL },
+ [FTP_PASS] = { "PASS etherboot@etherboot.org", NULL },
+ [FTP_TYPE] = { "TYPE I", NULL },
+ [FTP_PASV] = { "PASV", NULL },
+ [FTP_RETR] = { "RETR ", ftp_uri_path },
+ [FTP_WAIT] = { NULL, NULL },
+ [FTP_QUIT] = { "QUIT", NULL },
+ [FTP_DONE] = { NULL, NULL },
};
/**
@@ -178,18 +194,23 @@ static void ftp_parse_value ( char **text, uint8_t *value, size_t len ) {
*
*/
static void ftp_next_state ( struct ftp_request *ftp ) {
+ struct ftp_control_string *ftp_string;
+ const char *literal;
+ const char *variable;
/* Move to next state */
if ( ftp->state < FTP_DONE )
ftp->state++;
/* Send control string if needed */
- if ( ftp_strings[ftp->state] != NULL ) {
- DBGC ( ftp, "FTP %p sending ", ftp );
- DBGC ( ftp, ftp_strings[ftp->state], ftp->uri->path );
- xfer_printf ( &ftp->control, ftp_strings[ftp->state],
- ftp->uri->path );
- }
+ ftp_string = &ftp_strings[ftp->state];
+ literal = ftp_string->literal;
+ variable = ( ftp_string->variable ?
+ ftp_string->variable ( ftp ) : "" );
+ if ( literal ) {
+ DBGC ( ftp, "FTP %p sending %s%s\n", ftp, literal, variable );
+ xfer_printf ( &ftp->control, "%s%s\r\n", literal, variable );
+ }
}
/**