Add printflike to all printf like functions

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-07-17 14:05:23 +08:00 committed by Petro Karashchenko
parent 5c84c47cad
commit c252ec1481
31 changed files with 143 additions and 138 deletions

View File

@ -36,7 +36,7 @@
* Private Function Prototypes
****************************************************************************/
static void modprint(FAR const char *fmt, ...);
static void modprint(FAR const char *fmt, ...) printflike(1, 2);
/****************************************************************************
* Private Data

View File

@ -37,7 +37,7 @@
****************************************************************************/
#if CONFIG_MODLIB_MAXDEPEND > 0
void modprint(FAR const char *fmt, ...);
void modprint(FAR const char *fmt, ...) printflike(1, 2);
#endif
/****************************************************************************

View File

@ -89,8 +89,7 @@
#define MOUSE_X_POS (Mouse_status.x)
#define MOUSE_Y_POS (Mouse_status.y)
/*
* Bits associated with the .changes field:
/* Bits associated with the .changes field:
* 3 2 1 0
* 210987654321098765432109876543210
* 1 <- button 1 has changed
@ -139,8 +138,9 @@
#define BUTTON3_MOVED 0x00004000L /* PDCurses */
/* For the ncurses-compatible functions only, BUTTON4_PRESSED and
BUTTON5_PRESSED are returned for mouse scroll wheel up and down;
otherwise PDCurses doesn't support buttons 4 and 5 */
* BUTTON5_PRESSED are returned for mouse scroll wheel up and down;
* otherwise PDCurses doesn't support buttons 4 and 5
*/
#define BUTTON4_RELEASED 0x00008000L
#define BUTTON4_PRESSED 0x00010000L
@ -200,9 +200,9 @@
*
* long form:
*
* ----------------------------------------------------------------------------
* |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|..| 3| 2| 1| 0|
* ----------------------------------------------------------------------------
* -------------------------------------------------------------------------
* |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|..| 3| 2| 1| 0|
* -------------------------------------------------------------------------
* color number | modifiers | character eg 'a'
*
* The available non-color attributes are bold, underline, invisible,
@ -345,8 +345,7 @@
#define ACS_LANTERN ACS_PICK('i', '*')
#define ACS_BLOCK ACS_PICK('0', '#')
/* That goes double for these -- undocumented SysV symbols. Don't use
them. */
/* That goes double for these -- undocumented SysV symbols. Don't use them. */
#define ACS_S3 ACS_PICK('p', '-')
#define ACS_S7 ACS_PICK('r', '-')
@ -799,9 +798,12 @@ typedef unsigned long mmask_t;
typedef struct
{
short id; /* unused, always 0 */
int x, y, z; /* x, y same as MOUSE_STATUS; z unused */
int x; /* x, y same as MOUSE_STATUS; z unused */
int y;
int z;
mmask_t bstate; /* equivalent to changes + button[], but
* in the same format as used for mousemask() */
* in the same format as used for mousemask()
*/
} MEVENT;
/* PDCurses Structure Definitions */
@ -830,7 +832,8 @@ typedef struct _win /* definition of a window */
int _tmarg; /* top of scrolling region */
int _bmarg; /* bottom of scrolling region */
int _delayms; /* milliseconds of delay for getch() */
int _parx, _pary; /* coords relative to parent (0,0) */
int _parx; /* coords relative to parent (0,0) */
int _pary;
struct _win *_parent; /* subwin's pointer to parent win */
} WINDOW;
@ -858,6 +861,7 @@ typedef struct
int orig_cursor; /* original cursor size */
int lines; /* new value for LINES */
int cols; /* new value for COLS */
unsigned long _trap_mbe; /* trap these mouse button events */
unsigned long _map_mbe_to_key; /* map mouse buttons to slk */
int mouse_wait; /* time to wait (in ms) for a
@ -942,9 +946,9 @@ struct pdc_context_s
short COLOR_PAIRS;
short TABSIZE;
short first_col;
short c_pindex; /* putter index */
short c_gindex; /* getter index */
short c_ungind; /* ungetch() push index */
short c_pindex; /* putter index */
short c_gindex; /* getter index */
short c_ungind; /* ungetch() push index */
short c_ungch[NUNGETCH]; /* array of ungotten chars */
short c_buffer[_INBUFSIZ]; /* character buffer */
RIPPEDOFFLINE linesripped[5];
@ -1026,8 +1030,8 @@ void PDC_ctx_free(void);
#define graphic_screen ctx->graphic_screen
#endif
void* pdc_alloc_panel_ctx(void);
void* pdc_alloc_term_ctx(void);
void *pdc_alloc_panel_ctx(void);
void *pdc_alloc_term_ctx(void);
#else
@ -1072,7 +1076,8 @@ int baudrate(void);
int beep(void);
int bkgd(chtype);
void bkgdset(chtype);
int border(chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype);
int border(chtype, chtype, chtype, chtype,
chtype, chtype, chtype, chtype);
int box(WINDOW *, chtype, chtype);
bool can_change_color(void);
int cbreak(void);
@ -1160,8 +1165,8 @@ int mvinsch(int, int, chtype);
int mvinsnstr(int, int, const char *, int);
int mvinsstr(int, int, const char *);
int mvinstr(int, int, char *);
int mvprintw(int, int, const char *, ...);
int mvscanw(int, int, const char *, ...);
int mvprintw(int, int, const char *, ...) printflike(3, 4);
int mvscanw(int, int, const char *, ...) scanflike(3, 4);
int mvvline(int, int, chtype, int);
int mvwaddchnstr(WINDOW *, int, int, const chtype *, int);
int mvwaddchstr(WINDOW *, int, int, const chtype *);
@ -1183,8 +1188,8 @@ int mvwinsnstr(WINDOW *, int, int, const char *, int);
int mvwinsstr(WINDOW *, int, int, const char *);
int mvwinstr(WINDOW *, int, int, char *);
int mvwin(WINDOW *, int, int);
int mvwprintw(WINDOW *, int, int, const char *, ...);
int mvwscanw(WINDOW *, int, int, const char *, ...);
int mvwprintw(WINDOW *, int, int, const char *, ...) printflike(4, 5);
int mvwscanw(WINDOW *, int, int, const char *, ...) scanflike(4, 5);
int mvwvline(WINDOW *, int, int, chtype, int);
int napms(int);
WINDOW *newpad(int, int);
@ -1204,7 +1209,7 @@ int pair_content(short, short *, short *);
int pechochar(WINDOW *, chtype);
int pnoutrefresh(WINDOW *, int, int, int, int, int, int);
int prefresh(WINDOW *, int, int, int, int, int, int);
int printw(const char *, ...);
int printw(const char *, ...) printflike(1, 2);
int putwin(WINDOW *, FILE *);
void qiflush(void);
int raw(void);
@ -1215,7 +1220,7 @@ int reset_shell_mode(void);
int resetty(void);
int ripoffline(int, int (*)(WINDOW *, int));
int savetty(void);
int scanw(const char *, ...);
int scanw(const char *, ...) scanflike(1, 2);
int scr_dump(const char *);
int scr_init(const char *);
int scr_restore(const char *);
@ -1260,10 +1265,10 @@ int vid_attr(attr_t, short, void *);
int vidputs(chtype, int (*)(int));
int vid_puts(attr_t, short, void *, int (*)(int));
int vline(chtype, int);
int vw_printw(WINDOW *, const char *, va_list);
int vwprintw(WINDOW *, const char *, va_list);
int vw_scanw(WINDOW *, const char *, va_list);
int vwscanw(WINDOW *, const char *, va_list);
int vw_printw(WINDOW *, const char *, va_list) printflike(2, 0);
int vwprintw(WINDOW *, const char *, va_list) printflike(2, 0);
int vw_scanw(WINDOW *, const char *, va_list) scanflike(2, 0);
int vwscanw(WINDOW *, const char *, va_list) scanflike(2, 0);
int waddchnstr(WINDOW *, const chtype *, int);
int waddchstr(WINDOW *, const chtype *);
int waddch(WINDOW *, const chtype);
@ -1306,10 +1311,10 @@ int winsstr(WINDOW *, const char *);
int winstr(WINDOW *, char *);
int wmove(WINDOW *, int, int);
int wnoutrefresh(WINDOW *);
int wprintw(WINDOW *, const char *, ...);
int wprintw(WINDOW *, const char *, ...) printflike(2, 3);
int wredrawln(WINDOW *, int, int);
int wrefresh(WINDOW *);
int wscanw(WINDOW *, const char *, ...);
int wscanw(WINDOW *, const char *, ...) scanflike(2, 3);
int wscrl(WINDOW *, int);
int wsetscrreg(WINDOW *, int, int);
int wstandend(WINDOW *);
@ -1386,8 +1391,9 @@ int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int);
int mvwin_wchstr(WINDOW *, int, int, cchar_t *);
int mvwinwstr(WINDOW *, int, int, wchar_t *);
int mvwvline_set(WINDOW *, int, int, const cchar_t *, int);
int pecho_wchar(WINDOW *, const cchar_t*);
int setcchar(cchar_t*, const wchar_t*, const attr_t, short, const void*);
int pecho_wchar(WINDOW *, const cchar_t *);
int setcchar(cchar_t *, const wchar_t *, const attr_t,
short, const void *);
int slk_wset(int, const wchar_t *, int);
int unget_wch(const wchar_t);
int vline_set(const cchar_t *, int);
@ -1491,7 +1497,7 @@ char wordchar(void);
wchar_t *slk_wlabel(int);
#endif
void PDC_debug(const char *, ...);
void PDC_debug(const char *, ...) printflike(1, 2);
int PDC_ungetch(int);
int PDC_set_blink(bool);
int PDC_set_line_color(short);

View File

@ -510,7 +510,7 @@ namespace NXWidgets
* @return New CNxString instance.
*/
static CNxString format(const char *fmt, ...);
static CNxString format(const char *fmt, ...) printflike(1, 2);
};
}

View File

@ -586,7 +586,8 @@ void telnet_begin_compress2(struct telnet_s *telnet);
*
****************************************************************************/
int telnet_printf(struct telnet_s *telnet, const char *fmt, ...);
int telnet_printf(struct telnet_s *telnet, const char *fmt, ...)
printflike(2, 3);
/****************************************************************************
* Name: telnet_vprintf
@ -598,7 +599,8 @@ int telnet_printf(struct telnet_s *telnet, const char *fmt, ...);
*
****************************************************************************/
int telnet_vprintf(struct telnet_s *telnet, const char *fmt, va_list va);
int telnet_vprintf(struct telnet_s *telnet, const char *fmt, va_list va)
printflike(2, 0);
/****************************************************************************
* Name: telnet_raw_printf
@ -619,7 +621,8 @@ int telnet_vprintf(struct telnet_s *telnet, const char *fmt, va_list va);
*
****************************************************************************/
int telnet_raw_printf(struct telnet_s *telnet, const char *fmt, ...);
int telnet_raw_printf(struct telnet_s *telnet, const char *fmt, ...)
printflike(2, 3);
/****************************************************************************
* Name: telnet_raw_vprintf
@ -631,7 +634,8 @@ int telnet_raw_printf(struct telnet_s *telnet, const char *fmt, ...);
*
****************************************************************************/
int telnet_raw_vprintf(struct telnet_s *telnet, const char *fmt, va_list va);
int telnet_raw_vprintf(struct telnet_s *telnet, const char *fmt, va_list va)
printflike(2, 0);
/****************************************************************************
* Name: telnet_begin_newenviron

View File

@ -40,11 +40,9 @@
* POSSIBILITY OF SUCH DAMAGE.
****************************************************************************/
/*
* Lightweight Embedded XML-RPC Server Types and Definitions
*
* mtj@cogitollc.com
/* Lightweight Embedded XML-RPC Server Types and Definitions
*
* mtj@cogitollc.com
*/
#ifndef __APPS_INCLUDE_NETUTILS_XMLRPC_H
@ -86,13 +84,13 @@ struct xmlrpc_arg_s
int i;
char boolean;
double d;
char string[CONFIG_XMLRPC_STRINGSIZE+1];
char string[CONFIG_XMLRPC_STRINGSIZE + 1];
} u;
};
struct xmlrpc_s
{
char name[CONFIG_XMLRPC_STRINGSIZE+1];
char name[CONFIG_XMLRPC_STRINGSIZE + 1];
struct xmlrpc_arg_s arguments[MAX_ARGS];
char args[MAX_ARGS];
int argsize;
@ -104,7 +102,7 @@ struct xmlrpc_s
struct xmlrpc_entry_s
{
struct xmlrpc_entry_s *next;
int (*func)(struct xmlrpc_s*);
int (*func)(struct xmlrpc_s *);
char *name;
};

View File

@ -83,7 +83,7 @@
#define STRAYELSE2 STATIC+46, _("`else' without `end if'")
#define STRAYENDIF STATIC+47, _("`end if' without multiline `if' or `else'")
#define STRAYSUBEND STATIC+49, _("`subend', `end sub' or `endproc' without `sub' or `def proc' inside %s")
#define STRAYSUBEXIT STATIC+50, _("`subexit' without `sub' inside %s")
#define STRAYSUBEXIT STATIC+50, _("`subexit' without `sub' inside")
#define STRAYENDSELECT STATIC+51, _("`end select' without `select case'")
#define STRAYENDFN STATIC+52, _("`end function' without `def fn' or `function'")
#define STRAYENDEQ STATIC+53, _("`=' returning from function without `def fn'")

View File

@ -1241,7 +1241,7 @@ struct Value *stmt_EDIT(struct Value *value)
return (struct Value *)0;
#else
return Value_new_ERROR(value, NOTAVAILABLE, strerror(ENOSYS));
return Value_new_ERROR(value, NOTAVAILABLE);
#endif
}
@ -3526,7 +3526,7 @@ struct Value *stmt_MATINPUT(struct Value *value)
if (var->dim != 1 && var->dim != 2)
{
return Value_new_ERROR(value, NOMATRIX, var->dim);
return Value_new_ERROR(value, DIMENSION);
}
columns = var->dim == 1 ? 0 : var->geometry[1];
@ -5772,7 +5772,7 @@ struct Value *stmt_SHELL(struct Value *value)
return (struct Value *)0;
#else
return Value_new_ERROR(value, NOTAVAILABLE, strerror(ENOSYS));
return Value_new_ERROR(value, NOTAVAILABLE);
#endif
}

View File

@ -14,7 +14,7 @@
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
@ -64,7 +64,8 @@ struct String *String_clone(struct String *this, const struct String *clon);
int String_appendString(struct String *this, const struct String *app);
int String_appendChar(struct String *this, char ch);
int String_appendChars(struct String *this, const char *ch);
int String_appendPrintf(struct String *this, const char *fmt, ...);
int String_appendPrintf(struct String *this, const char *fmt, ...)
printflike(2, 3);
int String_insertChar(struct String *this, size_t where, char ch);
int String_delete(struct String *this, size_t where, size_t len);
void String_ucase(struct String *this);

View File

@ -14,7 +14,7 @@
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
@ -58,7 +58,7 @@
enum ValueType
{
V_ERROR=1,
V_ERROR = 1,
V_INTEGER,
V_NIL,
V_REAL,
@ -71,12 +71,16 @@ struct Value
enum ValueType type;
union
{
/* V_ERROR */ struct { char *msg; long int code; } error;
/* V_INTEGER */ long int integer;
/* V_NIL */
/* V_REAL */ double real;
/* V_STRING */ struct String string;
/* V_VOID */
struct /* V_ERROR */
{
char *msg;
long int code;
} error;
long int integer; /* V_INTEGER */
/* V_NIL */
double real; /* V_REAL */
struct String string; /* V_STRING */
/* V_VOID */
} u;
};
@ -84,7 +88,7 @@ struct Value
* Public Data
****************************************************************************/
extern const enum ValueType Value_commonType[V_VOID+1][V_VOID+1];
extern const enum ValueType Value_commonType[V_VOID + 1][V_VOID + 1];
/****************************************************************************
* Public Function Prototypes
@ -99,7 +103,7 @@ double Value_vald(const char *s, char **end, int *overflow);
struct Value *Value_new_NIL(struct Value *this);
struct Value *Value_new_ERROR(struct Value *this, int code,
const char *error, ...);
const char *error, ...) printflike(3, 4);
struct Value *Value_new_INTEGER(struct Value *this, int n);
struct Value *Value_new_REAL(struct Value *this, double n);
struct Value *Value_new_STRING(struct Value *this);

View File

@ -81,7 +81,7 @@ typedef enum
void vMBPortEnterCritical(void);
void vMBPortExitCritical(void);
void vMBPortLog(eMBPortLogLevel eLevel, const char *szModule,
const char *szFmt, ...);
const char *szFmt, ...) printflike(3, 4);
void vMBPortTimerPoll(void);
bool xMBPortSerialPoll(void);
bool xMBPortSerialSetTimeout(uint32_t dwTimeoutMs);
@ -90,7 +90,7 @@ bool xMBPortSerialSetTimeout(uint32_t dwTimeoutMs);
void vMBMasterPortEnterCritical(void);
void vMBMasterPortExitCritical(void);
void vMBMasterPortLog(eMBPortLogLevel eLevel, const char *szModule,
const char *szFmt, ...);
const char *szFmt, ...) printflike(3, 4);
void vMBMasterPortTimerPoll(void);
bool xMBMasterPortSerialPoll(void);
bool xMBMasterPortSerialSetTimeout(uint32_t dwTimeoutMs);

View File

@ -25,6 +25,7 @@
#include "ftpc_config.h"
#include <sys/stat.h>
#include <inttypes.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@ -95,7 +96,7 @@ static int ftpc_recvinit(struct ftpc_session_s *session,
* transfer should start. This must come after PORT or PASV commands.
*/
ret = ftpc_cmd(session, "REST %ld", offset);
ret = ftpc_cmd(session, "REST %" PRIdOFF, offset);
if (ret < 0)
{
nwarn("WARNING: REST command failed: %d\n", errno);

View File

@ -226,7 +226,8 @@ EXTERN int ftpc_relogin(FAR struct ftpc_session_s *session);
/* FTP helpers */
EXTERN void ftpc_reset(struct ftpc_session_s *session);
EXTERN int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...);
EXTERN int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
printflike(2, 3);
EXTERN int fptc_getreply(struct ftpc_session_s *session);
EXTERN FAR const char *ftpc_lpwd(void);
EXTERN int ftpc_xfrmode(struct ftpc_session_s *session, uint8_t xfrmode);
@ -252,7 +253,7 @@ EXTERN void ftpc_sockcopy(FAR struct ftpc_socket_s *dest,
/* Socket I/O helpers */
EXTERN int ftpc_sockprintf(FAR struct ftpc_socket_s *sock,
const char *fmt, ...);
const char *fmt, ...) printflike(2, 3);
EXTERN void ftpc_timeout(wdparm_t arg);
/* Transfer helpers */

View File

@ -26,6 +26,7 @@
#include <sys/stat.h>
#include <sys/sendfile.h>
#include <inttypes.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@ -263,7 +264,7 @@ static int ftpc_sendfile(struct ftpc_session_s *session, const char *path,
if (session->offset > 0)
{
ret = ftpc_cmd(session, "REST %ld", session->offset);
ret = ftpc_cmd(session, "REST %" PRIdOFF, session->offset);
session->size = session->offset;
}

View File

@ -108,7 +108,8 @@ static int ftpd_accept(int sd, FAR void *addr, FAR socklen_t *addrlen,
static ssize_t ftpd_recv(int sd, FAR void *data, size_t size, int timeout);
static ssize_t ftpd_send(int sd, FAR const void *data, size_t size,
int timeout);
static ssize_t ftpd_response(int sd, int timeout, FAR const char *fmt, ...);
static ssize_t ftpd_response(int sd, int timeout, FAR const char *fmt, ...)
printflike(3, 4);
static int ftpd_dataopen(FAR struct ftpd_session_s *session);
static int ftpd_dataclose(FAR struct ftpd_session_s *session);

View File

@ -63,9 +63,9 @@ static void nsh_consolerelease(FAR struct nsh_vtbl_s *vtbl);
static ssize_t nsh_consolewrite(FAR struct nsh_vtbl_s *vtbl,
FAR const void *buffer, size_t nbytes);
static int nsh_consoleoutput(FAR struct nsh_vtbl_s *vtbl,
FAR const char *fmt, ...);
FAR const char *fmt, ...) printflike(2, 3);
static int nsh_erroroutput(FAR struct nsh_vtbl_s *vtbl,
FAR const char *fmt, ...);
FAR const char *fmt, ...) printflike(2, 3);
static FAR char *nsh_consolelinebuffer(FAR struct nsh_vtbl_s *vtbl);
static void nsh_consoleredirect(FAR struct nsh_vtbl_s *vtbl, int fd,
FAR uint8_t *save);

View File

@ -112,8 +112,10 @@ struct nsh_vtbl_s
void (*release)(FAR struct nsh_vtbl_s *vtbl);
ssize_t (*write)(FAR struct nsh_vtbl_s *vtbl, FAR const void *buffer,
size_t nbytes);
int (*error)(FAR struct nsh_vtbl_s *vtbl, FAR const char *fmt, ...);
int (*output)(FAR struct nsh_vtbl_s *vtbl, FAR const char *fmt, ...);
int (*error)(FAR struct nsh_vtbl_s *vtbl, FAR const char *fmt, ...)
printflike(2, 3);
int (*output)(FAR struct nsh_vtbl_s *vtbl, FAR const char *fmt, ...)
printflike(2, 3);
FAR char *(*linebuffer)(FAR struct nsh_vtbl_s *vtbl);
void (*redirect)(FAR struct nsh_vtbl_s *vtbl, int fd, FAR uint8_t *save);
void (*undirect)(FAR struct nsh_vtbl_s *vtbl, FAR uint8_t *save);

View File

@ -166,7 +166,7 @@ int cmd_mb(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
/* Make sure we end it with a newline */
nsh_output(vtbl, "\n", *ptr);
nsh_output(vtbl, "\n");
}
}
@ -222,7 +222,7 @@ int cmd_mh(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
/* Make sure we end it with a newline */
nsh_output(vtbl, "\n", *ptr);
nsh_output(vtbl, "\n");
}
}
@ -252,7 +252,7 @@ int cmd_mw(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
{
/* Print the value at the address */
nsh_output(vtbl, " %p = 0x%08x", ptr, *ptr);
nsh_output(vtbl, " %p = 0x%08" PRIx32, ptr, *ptr);
/* Are we supposed to write a value to this address? */
@ -264,12 +264,12 @@ int cmd_mw(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
*/
*ptr = mem.dm_value;
nsh_output(vtbl, " -> 0x%08x", *ptr);
nsh_output(vtbl, " -> 0x%08" PRIx32, *ptr);
}
/* Make sure we end it with a newline */
nsh_output(vtbl, "\n", *ptr);
nsh_output(vtbl, "\n");
}
}

View File

@ -25,6 +25,7 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdbool.h>
@ -245,7 +246,7 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
if ((lsflags & LSFLAGS_SIZE) != 0)
{
nsh_output(vtbl, "%8d", buf.st_size);
nsh_output(vtbl, "%8" PRIdOFF, buf.st_size);
}
}
@ -1873,7 +1874,7 @@ int cmd_cmp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
if (nbytesread1 != nbytesread2 ||
memcmp(buf1, buf2, nbytesread1) != 0)
{
nsh_error(vtbl, "files differ: byte %u\n", total_read);
nsh_error(vtbl, "files differ: byte %" PRIuOFF "\n", total_read);
goto errout_with_fd2;
}

View File

@ -75,15 +75,11 @@ int nsh_catfile(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
strlen(CONFIG_NSH_PROC_MOUNTPOINT)) == 0)
{
nsh_error(vtbl,
"nsh: %s: Could not open %s (is procfs mounted?): %d\n",
cmd, filepath, NSH_ERRNO);
"nsh: %s: Could not open %s (is procfs mounted?)\n",
cmd, filepath);
}
else
#endif
{
nsh_error(vtbl, g_fmtcmdfailed, cmd, "open", NSH_ERRNO);
}
nsh_error(vtbl, g_fmtcmdfailed, cmd, "open", NSH_ERRNO);
return ERROR;
}
@ -322,15 +318,11 @@ int nsh_writefile(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
strlen(CONFIG_NSH_PROC_MOUNTPOINT)) == 0)
{
nsh_error(vtbl,
"nsh: %s: Could not open %s (is procfs mounted?): %d\n",
cmd, filepath, NSH_ERRNO);
"nsh: %s: Could not open %s (is procfs mounted?)\n",
cmd, filepath);
}
else
#endif
{
nsh_error(vtbl, g_fmtcmdfailed, cmd, "open", NSH_ERRNO);
}
nsh_error(vtbl, g_fmtcmdfailed, cmd, "open", NSH_ERRNO);
return ERROR;
}
@ -384,15 +376,11 @@ int nsh_foreach_direntry(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
strlen(CONFIG_NSH_PROC_MOUNTPOINT)) == 0)
{
nsh_error(vtbl,
"nsh: %s: Could not open %s (is procfs mounted?): %d\n",
cmd, dirpath, NSH_ERRNO);
"nsh: %s: Could not open %s (is procfs mounted?)\n",
cmd, dirpath);
}
else
#endif
{
nsh_error(vtbl, g_fmtnosuch, cmd, "directory", dirpath);
}
nsh_error(vtbl, g_fmtcmdfailed, cmd, "opendir", NSH_ERRNO);
return ERROR;
}

View File

@ -377,8 +377,9 @@ static int nsh_foreach_netdev(nsh_netdev_callback_t callback,
if (dir == NULL)
{
nsh_error(vtbl,
"nsh: %s: Could not open %s/net (is procfs mounted?): %d\n",
cmd, CONFIG_NSH_PROC_MOUNTPOINT, NSH_ERRNO);
"nsh: %s: Could not open %s/net (is procfs mounted?)\n",
cmd, CONFIG_NSH_PROC_MOUNTPOINT);
nsh_error(vtbl, g_fmtcmdfailed, cmd, "opendir", NSH_ERRNO);
return ERROR;
}

View File

@ -48,7 +48,7 @@ int cmd_printf(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
FAR char *fmt;
char ch;
uint32_t value;
unsigned int value;
int len;
int i;

View File

@ -233,13 +233,13 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
int ret;
int i;
#if defined(CONFIG_DEBUG_MM) && !defined(CONFIG_NSH_DISABLE_PSHEAPUSAGE)
uint32_t heap_size;
unsigned long heap_size = 0;
#endif
#if !defined(CONFIG_NSH_DISABLE_PSSTACKUSAGE)
uint32_t stack_size;
unsigned long stack_size = 0;
#ifdef CONFIG_STACK_COLORATION
uint32_t stack_used;
uint32_t stack_filled;
unsigned long stack_used = 0;
unsigned long stack_filled = 0;
#endif
#endif
@ -343,9 +343,7 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
#if defined(CONFIG_DEBUG_MM) && !defined(CONFIG_NSH_DISABLE_PSHEAPUSAGE)
/* Get the Heap AllocSize */
heap_size = 0;
filepath = NULL;
ret = asprintf(&filepath, "%s/%s/heap", dirpath, entryp->d_name);
if (ret < 0 || filepath == NULL)
{
@ -393,7 +391,7 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
if (strncmp(line, g_heapsize, strlen(g_heapsize)) == 0)
{
heap_size = (uint32_t)atoi(&line[12]);
heap_size = strtoul(&line[12], NULL, 0);
break;
}
}
@ -401,18 +399,13 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
}
}
nsh_output(vtbl, "%08u ", (unsigned int)heap_size);
nsh_output(vtbl, "%08lu ", heap_size);
#endif
#if !defined(CONFIG_NSH_DISABLE_PSSTACKUSAGE)
/* Get the StackSize and StackUsed */
stack_size = 0;
#ifdef CONFIG_STACK_COLORATION
stack_used = 0;
#endif
filepath = NULL;
ret = asprintf(&filepath, "%s/%s/stack", dirpath, entryp->d_name);
if (ret < 0 || filepath == NULL)
{
@ -461,12 +454,12 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
if (strncmp(line, g_stacksize, strlen(g_stacksize)) == 0)
{
stack_size = (uint32_t)atoi(&line[12]);
stack_size = strtoul(&line[12], NULL, 0);
}
#ifdef CONFIG_STACK_COLORATION
else if (strncmp(line, g_stackused, strlen(g_stackused)) == 0)
{
stack_used = (uint32_t)atoi(&line[12]);
stack_used = strtoul(&line[12], NULL, 0);
}
#endif
}
@ -474,12 +467,11 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
}
}
nsh_output(vtbl, "%06u ", (unsigned int)stack_size);
nsh_output(vtbl, "%06lu ", stack_size);
#ifdef CONFIG_STACK_COLORATION
nsh_output(vtbl, "%06u ", (unsigned int)stack_used);
nsh_output(vtbl, "%06lu ", stack_used);
stack_filled = 0;
if (stack_size > 0 && stack_used > 0)
{
/* Use fixed-point math with one decimal place */
@ -489,7 +481,7 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
/* Additionally print a '!' if the stack is filled more than 80% */
nsh_output(vtbl, "%3d.%1d%%%c ",
nsh_output(vtbl, "%3lu.%lu%%%c ",
stack_filled / 10, stack_filled % 10,
(stack_filled >= 10 * 80 ? '!' : ' '));
#endif

View File

@ -217,7 +217,7 @@ int cmd_pmconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
boardctl(BOARDIOC_PM_CONTROL, (uintptr_t)&ctrl);
sleep_count = ctrl.count;
nsh_output(vtbl, "Last state %d, Next state %d",
nsh_output(vtbl, "Last state %d, Next state %d"
"PM stay [%d, %d, %d, %d]\n",
last_state, next_state, normal_count, idle_count,
standby_count, sleep_count);
@ -611,7 +611,7 @@ int cmd_uname(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
nsh_output(vtbl, " ");
}
nsh_output(vtbl, str);
nsh_output(vtbl, "%s", str);
first = false;
}
}

View File

@ -153,7 +153,7 @@ struct cle_s
****************************************************************************/
#if CONFIG_SYSTEM_CLE_DEBUGLEVEL > 0
static void cle_debug(FAR const char *fmt, ...);
static void cle_debug(FAR const char *fmt, ...) printflike(1, 2);
#endif
/* Low-level display and data entry functions */

View File

@ -5,7 +5,8 @@
* Copyright (c) 2011, B.ZaaR, All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
@ -18,7 +19,7 @@
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

View File

@ -140,7 +140,7 @@ static int i2ccmd_help(FAR struct i2ctool_s *i2ctool, int argc, char **argv)
i2ctool->autoincr ? "YES" : "NO");
i2ctool_printf(i2ctool,
" [-f freq] I2C frequency."
" Default: %d Current: %d\n",
" Default: %d Current: %" PRIu32 "\n",
CONFIG_I2CTOOL_DEFFREQ, i2ctool->freq);
i2ctool_printf(i2ctool, "\nSpecial non-sticky options:\n");

View File

@ -170,7 +170,8 @@ extern const char g_i2cxfrerror[];
ssize_t i2ctool_write(FAR struct i2ctool_s *i2ctool, FAR const void *buffer,
size_t nbytes);
int i2ctool_printf(FAR struct i2ctool_s *i2ctool, const char *fmt, ...);
int i2ctool_printf(FAR struct i2ctool_s *i2ctool, const char *fmt, ...)
printflike(2, 3);
void i2ctool_flush(FAR struct i2ctool_s *i2ctool);
void i2ctool_hexdump(FILE *outstream, void *addr, int len);

View File

@ -122,7 +122,7 @@ static int spicmd_help(FAR struct spitool_s *spitool, int argc,
CONFIG_SPITOOL_DEFCMD, spitool->command);
#endif
spitool_printf(spitool, " [-f freq] SPI frequency. "
"Default: %d Current: %d\n",
"Default: %d Current: %" PRIu32 "\n",
CONFIG_SPITOOL_DEFFREQ, spitool->freq);
spitool_printf(spitool, " [-m mode] Mode for transfer. "
@ -130,23 +130,24 @@ static int spicmd_help(FAR struct spitool_s *spitool, int argc,
CONFIG_SPITOOL_DEFMODE, spitool->mode);
spitool_printf(spitool, " [-n CSn] chip select number. "
"Default: %d Current: %d\n",
"Default: %d Current: %" PRIu32 "\n",
0, spitool->csn);
spitool_printf(spitool, " [-t devtype] Chip Select type "
"(see spi_devtype_e). "
"Default: %d Current: %d\n",
"Default: %d Current: %" PRIu32 "\n",
SPIDEVTYPE_USER, spitool->devtype);
spitool_printf(spitool, " [-u udelay] Delay after transfer in uS. "
"Default: 0 Current: %d\n", spitool->udelay);
"Default: 0 Current: %" PRIu32 "\n",
spitool->udelay);
spitool_printf(spitool, " [-w width] Width of bus. "
"Default: %d Current: %d\n",
CONFIG_SPITOOL_DEFWIDTH, spitool->width);
spitool_printf(spitool, " [-x count] Words to exchange "
"Default: %d Current: %d Max: %d\n",
"Default: %d Current: %" PRIu32 " Max: %d\n",
CONFIG_SPITOOL_DEFWORDS, spitool->count, MAX_XDATA);
spitool_printf(spitool, "\nNOTES:\n");

View File

@ -176,7 +176,8 @@ extern const char g_spixfrerror[];
ssize_t spitool_exchange(FAR struct spitool_s *spitool,
FAR const void *outbuffer, size_t noutbytes,
FAR void *inbuffer, size_t ninbytes);
int spitool_printf(FAR struct spitool_s *spitool, const char *fmt, ...);
int spitool_printf(FAR struct spitool_s *spitool, const char *fmt, ...)
printflike(2, 3);
void spitool_flush(FAR struct spitool_s *spitool);
/* Command handlers */

View File

@ -391,7 +391,7 @@ static void vi_clrscreen(FAR struct vi_s *vi);
/* Final Line display */
static void vi_printf(FAR struct vi_s *vi, FAR const char *prefix,
FAR const char *fmt, ...);
FAR const char *fmt, ...) printflike(3, 4);
/* Line positioning */