Annotate format strings. Add a bunch of int casts for size limits.

This commit is contained in:
joerg 2014-01-07 02:13:00 +00:00
parent bbb837ac5b
commit eec35cced6
3 changed files with 11 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: common.h,v 1.1.1.7 2010/03/24 20:51:42 joerg Exp $ */ /* $NetBSD: common.h,v 1.2 2014/01/07 02:13:00 joerg Exp $ */
/*- /*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* All rights reserved. * All rights reserved.
@ -90,7 +90,7 @@ struct fetcherr {
void fetch_seterr(struct fetcherr *, int); void fetch_seterr(struct fetcherr *, int);
void fetch_syserr(void); void fetch_syserr(void);
void fetch_info(const char *, ...); void fetch_info(const char *, ...) __printflike(1, 2);
int fetch_default_port(const char *); int fetch_default_port(const char *);
int fetch_default_proxy_port(const char *); int fetch_default_proxy_port(const char *);
int fetch_bind(int, int, const char *); int fetch_bind(int, int, const char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ftp.c,v 1.6 2013/10/19 22:58:40 mrg Exp $ */ /* $NetBSD: ftp.c,v 1.7 2014/01/07 02:13:00 joerg Exp $ */
/*- /*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* Copyright (c) 2008, 2009, 2010 Joerg Sonnenberger <joerg@NetBSD.org> * Copyright (c) 2008, 2009, 2010 Joerg Sonnenberger <joerg@NetBSD.org>
@ -198,6 +198,7 @@ ftp_chkerr(conn_t *conn)
/* /*
* Send a command and check reply * Send a command and check reply
*/ */
__printflike(2, 3)
static int static int
ftp_cmd(conn_t *conn, const char *fmt, ...) ftp_cmd(conn_t *conn, const char *fmt, ...)
{ {
@ -391,7 +392,7 @@ ftp_cwd(conn_t *conn, const char *path, int subdir)
++beg, ++i; ++beg, ++i;
for (++i; dst + i < end && dst[i] != '/'; ++i) for (++i; dst + i < end && dst[i] != '/'; ++i)
/* nothing */ ; /* nothing */ ;
e = ftp_cmd(conn, "CWD %.*s\r\n", dst + i - beg, beg); e = ftp_cmd(conn, "CWD %.*s\r\n", (int)(dst + i - beg), beg);
if (e != FTP_FILE_ACTION_OK) { if (e != FTP_FILE_ACTION_OK) {
free(dst); free(dst);
ftp_seterr(e); ftp_seterr(e);
@ -489,7 +490,7 @@ ftp_stat(conn_t *conn, const char *file, struct url_stat *us)
return (-1); return (-1);
} }
e = ftp_cmd(conn, "SIZE %.*s\r\n", filenamelen, filename); e = ftp_cmd(conn, "SIZE %.*s\r\n", (int)filenamelen, filename);
if (e != FTP_FILE_STATUS) { if (e != FTP_FILE_STATUS) {
ftp_seterr(e); ftp_seterr(e);
return (-1); return (-1);
@ -506,7 +507,7 @@ ftp_stat(conn_t *conn, const char *file, struct url_stat *us)
if (us->size == 0) if (us->size == 0)
us->size = -1; us->size = -1;
e = ftp_cmd(conn, "MDTM %.*s\r\n", filenamelen, filename); e = ftp_cmd(conn, "MDTM %.*s\r\n", (int)filenamelen, filename);
if (e != FTP_FILE_STATUS) { if (e != FTP_FILE_STATUS) {
ftp_seterr(e); ftp_seterr(e);
return (-1); return (-1);
@ -851,7 +852,7 @@ retry_mode:
e = ftp_cmd(conn, "%s%s%s\r\n", oper, *op_arg ? " " : "", op_arg); e = ftp_cmd(conn, "%s%s%s\r\n", oper, *op_arg ? " " : "", op_arg);
else else
e = ftp_cmd(conn, "%s %.*s\r\n", oper, e = ftp_cmd(conn, "%s %.*s\r\n", oper,
filenamelen, filename); (int)filenamelen, filename);
if (e != FTP_CONNECTION_ALREADY_OPEN && e != FTP_OPEN_DATA_CONNECTION) if (e != FTP_CONNECTION_ALREADY_OPEN && e != FTP_OPEN_DATA_CONNECTION)
goto ouch; goto ouch;
@ -948,7 +949,7 @@ retry_mode:
e = ftp_cmd(conn, "%s%s%s\r\n", oper, *op_arg ? " " : "", op_arg); e = ftp_cmd(conn, "%s%s%s\r\n", oper, *op_arg ? " " : "", op_arg);
else else
e = ftp_cmd(conn, "%s %.*s\r\n", oper, e = ftp_cmd(conn, "%s %.*s\r\n", oper,
filenamelen, filename); (int)filenamelen, filename);
if (e != FTP_CONNECTION_ALREADY_OPEN && e != FTP_OPEN_DATA_CONNECTION) if (e != FTP_CONNECTION_ALREADY_OPEN && e != FTP_OPEN_DATA_CONNECTION)
goto ouch; goto ouch;

View File

@ -1,4 +1,4 @@
/* $NetBSD: http.c,v 1.2 2011/06/25 20:27:01 christos Exp $ */ /* $NetBSD: http.c,v 1.3 2014/01/07 02:13:00 joerg Exp $ */
/*- /*-
* Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav * Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav
* Copyright (c) 2003 Thomas Klausner <wiz@NetBSD.org> * Copyright (c) 2003 Thomas Klausner <wiz@NetBSD.org>
@ -404,6 +404,7 @@ static struct {
/* /*
* Send a formatted line; optionally echo to terminal * Send a formatted line; optionally echo to terminal
*/ */
__printflike(2, 3)
static int static int
http_cmd(conn_t *conn, const char *fmt, ...) http_cmd(conn_t *conn, const char *fmt, ...)
{ {