示例#1
0
}

void callnull(void){
  null(0,        0); // no error
  null(0, (char*)0); // no error
  null(0, (void*)0); // no error
  null(0,  (int*)0); // expected-warning {{incompatible pointer types}}
}



// PR4470
int xx_vprintf(const char *, va_list);

const char *foo(const char *format) __attribute__((format_arg(1)));

void __attribute__((format(printf, 1, 0)))
foo2(const char *fmt, va_list va) {
  xx_vprintf(foo(fmt), va);
}

// PR6542
extern void gcc_format (const char *, ...)
  __attribute__ ((__format__(__gcc_diag__, 1, 2)));
extern void gcc_cformat (const char *, ...)
  __attribute__ ((__format__(__gcc_cdiag__, 1, 2)));
extern void gcc_cxxformat (const char *, ...)
  __attribute__ ((__format__(__gcc_cxxdiag__, 1, 2)));
extern void gcc_tformat (const char *, ...)
  __attribute__ ((__format__(__gcc_tdiag__, 1, 2)));
示例#2
0
	unsigned long long hits;
	unsigned long long misses;
	unsigned long long allocations;
	unsigned long long reclaims;
	unsigned long long frees;
};

static int interval;
static int rows;
static char *progname;
static char buf[DEF_BUF_SIZE];

/* selinuxfs mount point */
extern char *selinux_mnt;

static __attribute__((__format__(printf,1,2),__noreturn__)) void die(const char *msg, ...)
{
	va_list args;

	fputs("ERROR: ", stderr);

	va_start(args, msg);
	vfprintf(stderr, msg, args);
	va_end(args);

	if (errno)
		fprintf(stderr, ": %s", strerror(errno));

	fputc('\n', stderr);
	exit(1);
}



extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);

extern int vsprintf (char *__restrict __s, const char *__restrict __format,
       __gnuc_va_list __arg) __attribute__ ((__nothrow__));





extern int snprintf (char *__restrict __s, size_t __maxlen,
       const char *__restrict __format, ...)
     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4)));

extern int vsnprintf (char *__restrict __s, size_t __maxlen,
        const char *__restrict __format, __gnuc_va_list __arg)
     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0)));

# 412 "/usr/include/stdio.h" 3 4
extern int vdprintf (int __fd, const char *__restrict __fmt,
       __gnuc_va_list __arg)
     __attribute__ ((__format__ (__printf__, 2, 0)));
extern int dprintf (int __fd, const char *__restrict __fmt, ...)
     __attribute__ ((__format__ (__printf__, 2, 3)));



示例#4
0
文件: print_cmd.c 项目: bminor/bash
#include "shmbutil.h"

#include "builtins/common.h"

#if !HAVE_DECL_PRINTF
extern int printf __P((const char *, ...));	/* Yuck.  Double yuck. */
#endif

static int indentation;
static int indentation_amount = 4;

#if defined (PREFER_STDARG)
typedef void PFUNC __P((const char *, ...));

static void cprintf __P((const char *, ...))  __attribute__((__format__ (printf, 1, 2)));
static void xprintf __P((const char *, ...))  __attribute__((__format__ (printf, 1, 2)));
#else
#define PFUNC VFunction
static void cprintf ();
static void xprintf ();
#endif

static void reset_locals __P((void));
static void newline __P((char *));
static void indent __P((int));
static void semicolon __P((void));
static void the_printed_command_resize __P((int));

static void make_command_string_internal __P((COMMAND *));
static void _print_word_list __P((WORD_LIST *, char *, PFUNC *));
示例#5
0
文件: xopen-2.c 项目: 0day-ci/gcc
/* Test for X/Open format extensions, as found in the
   Single Unix Specification.  Test for bug reported by
   Pierre-Canalsat PETIT <*****@*****.**>
   in PR c/6547.  The test for absence of a parameter for a * width was done
   too early in the case of operand numbers and vprintf formats.
*/
/* Origin: Joseph Myers <*****@*****.**> */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */

#include "format.h"

void vbar (va_list, const char *) __attribute__((__format__(__printf__, 2, 0)));

void
foo (int i, int j, va_list va)
{
  printf("%2$*1$c", i, j);
  printf("%2$*1$c %2$*1$c", i, j); /* { dg-bogus "matching" "bogus too few dollar" } */
  vbar(va, "%*s"); /* { dg-bogus "matching" "bogus too few vprintf" } */
}
示例#6
0
/* Test for ICE handling internal formats: bug 20740.  The code did
   not check that, if the required typedef names had been used as
   identifiers, they were defined to suitable types.  Test
   "__gcc_host_wide_int__", bad type.  */
/* Origin: Joseph Myers <*****@*****.**> */
/* { dg-do compile } */
/* { dg-options "-Wformat" } */

typedef int __gcc_host_wide_int__;
void bar (const char *, ...) __attribute__ ((__format__ (__gcc_diag__, 1, 2))); /* { dg-error "error: '__gcc_host_wide_int__' is not defined as 'long' or 'long long'" } */
示例#7
0
#include <signal.h>
#include <termios.h>
#include <sys/ioctl.h>

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <err.h>

in_addr_t giaddr;
in_addr_t netaddr;
in_addr_t circuit_addr;

int ssystem(const char *fmt, ...)
     __attribute__((__format__ (__printf__, 1, 2)));
void write_to_serial(int outfd, void *inbuf, int len);

//#define PROGRESS(s) fprintf(stderr, s)
#define PROGRESS(s) do { } while (0)

#define USAGE_STRING "usage: tapslip6 [-B baudrate] [-s siodev] [-t tundev] ipaddress netmask"

char tundev[32] = { "tap0" };

int
ssystem(const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2)));

int
ssystem(const char *fmt, ...)
{
示例#8
0
/* Test warnings for missing format attributes on function pointers.  */
/* Origin: Kaveh Ghazi <*****@*****.**> */
/* { dg-do compile } */
/* { dg-options "-Wmissing-format-attribute" } */
/* { dg-options "-Wmissing-format-attribute -Wno-abi" { target arm_eabi } } */

#include <stdarg.h>

typedef void (*noattr_t) (const char *, ...);
typedef noattr_t __attribute__ ((__format__(__printf__, 1, 2))) attr_t;

typedef void (*vnoattr_t) (const char *, va_list);
typedef vnoattr_t __attribute__ ((__format__(__printf__, 1, 0))) vattr_t;

void
foo1 (noattr_t na, attr_t a, vnoattr_t vna, vattr_t va)
{
  noattr_t na1 = na;
  noattr_t na2 = a; /* { dg-warning "candidate" "initialization warning" } */
  attr_t a1 = na;
  attr_t a2 = a;
  
  vnoattr_t vna1 = vna;
  vnoattr_t vna2 = va; /* { dg-warning "candidate" "initialization warning" } */
  vattr_t va1 = vna;
  vattr_t va2 = va;
}
示例#9
0
文件: newfs.c 项目: darksoul42/bitrig
#include <signal.h>
#include <util.h>

#include "mntopts.h"
#include "pathnames.h"

struct mntopt mopts[] = {
	MOPT_STDOPTS,
	MOPT_ASYNC,
	MOPT_UPDATE,
	MOPT_FORCE,
	{ NULL },
};

void	fatal(const char *fmt, ...)
	    __attribute__((__format__ (printf, 1, 2)))
	    __attribute__((__nonnull__ (1)));
__dead void	usage(void);
void	mkfs(struct partition *, char *, int, int);
void	getphysmem(void);
void	rewritelabel(char *, int, struct disklabel *);
u_short	dkcksum(struct disklabel *);

/*
 * The following two constants set the default block and fragment sizes.
 * Both constants must be a power of 2 and meet the following constraints:
 *	MINBSIZE <= DESBLKSIZE <= MAXBSIZE
 *	sectorsize <= DESFRAGSIZE <= DESBLKSIZE
 *	DESBLKSIZE / DESFRAGSIZE <= 8
 */
#define	DFL_FRAGSIZE	2048
示例#10
0
文件: multattr-1.c 项目: 0day-ci/gcc
/* Test for multiple format attributes.  Test for printf and scanf attributes
   together.  */
/* Origin: Joseph Myers <*****@*****.**> */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */

#define DONT_GNU_PROTOTYPE
#include "format.h"

/* If we specify multiple attributes for a single function, they should
   all apply.  This should apply whether they are on the same declaration
   or on different declarations.  */

extern void my_vprintf_scanf (const char *, va_list, const char *, ...)
     __attribute__((__format__(gnu_attr___printf__, 1, 0)))
     __attribute__((__format__(gnu_attr___scanf__, 3, 4)));

extern void my_vprintf_scanf2 (const char *, va_list, const char *, ...)
     __attribute__((__format__(gnu_attr___scanf__, 3, 4)))
     __attribute__((__format__(gnu_attr___printf__, 1, 0)));

extern void my_vprintf_scanf3 (const char *, va_list, const char *, ...)
     __attribute__((__format__(gnu_attr___printf__, 1, 0)));
extern void my_vprintf_scanf3 (const char *, va_list, const char *, ...)
     __attribute__((__format__(gnu_attr___scanf__, 3, 4)));

extern void my_vprintf_scanf4 (const char *, va_list, const char *, ...)
     __attribute__((__format__(gnu_attr___scanf__, 3, 4)));
extern void my_vprintf_scanf4 (const char *, va_list, const char *, ...)
     __attribute__((__format__(gnu_attr___printf__, 1, 0)));
extern FILE *fopen(const char *__restrict __filename, const char *__restrict __modes);
extern FILE *freopen(const char *__restrict __filename, const char *__restrict __modes, FILE *__restrict __stream);
extern FILE *fdopen(int __fd, const char *__modes) __attribute__((__nothrow__));
extern FILE *fmemopen(void *__s, size_t __len, const char *__modes) __attribute__((__nothrow__));
extern FILE *open_memstream(char **__bufloc, size_t *__sizeloc) __attribute__((__nothrow__));
extern void setbuf(FILE *__restrict __stream, char *__restrict __buf) __attribute__((__nothrow__));
extern int setvbuf(FILE *__restrict __stream, char *__restrict __buf, int __modes, size_t __n) __attribute__((__nothrow__));
extern void setbuffer(FILE *__restrict __stream, char *__restrict __buf, size_t __size) __attribute__((__nothrow__));
extern void setlinebuf(FILE *__stream) __attribute__((__nothrow__));
extern int fprintf(FILE *__restrict __stream, const char *__restrict __format, ...);
extern int printf(const char *__restrict __format, ...);
extern int sprintf(char *__restrict __s, const char *__restrict __format, ...) __attribute__((__nothrow__));
extern int vfprintf(FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg);
extern int vprintf(const char *__restrict __format, __gnuc_va_list __arg);
extern int vsprintf(char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __attribute__((__nothrow__));
extern int snprintf(char *__restrict __s, size_t __maxlen, const char *__restrict __format, ...) __attribute__((__nothrow__)) __attribute__((__format__(__printf__, 3, 4)));
extern int vsnprintf(char *__restrict __s, size_t __maxlen, const char *__restrict __format, __gnuc_va_list __arg) __attribute__((__nothrow__)) __attribute__((__format__(__printf__, 3, 0)));
extern int vdprintf(int __fd, const char *__restrict __fmt, __gnuc_va_list __arg) __attribute__((__format__(__printf__, 2, 0)));
extern int dprintf(int __fd, const char *__restrict __fmt, ...) __attribute__((__format__(__printf__, 2, 3)));
extern int fscanf(FILE *__restrict __stream, const char *__restrict __format, ...);
extern int scanf(const char *__restrict __format, ...);
extern int sscanf(const char *__restrict __s, const char *__restrict __format, ...) __attribute__((__nothrow__));
extern int fscanf(FILE *__restrict __stream, const char *__restrict __format, ...) __asm__ ("""__isoc99_fscanf");
extern int scanf(const char *__restrict __format, ...) __asm__ ("""__isoc99_scanf");
extern int sscanf(const char *__restrict __s, const char *__restrict __format, ...) __asm__ ("""__isoc99_sscanf") __attribute__((__nothrow__));
extern int vfscanf(FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __attribute__((__format__(__scanf__, 2, 0)));
extern int vscanf(const char *__restrict __format, __gnuc_va_list __arg) __attribute__((__format__(__scanf__, 1, 0)));
extern int vsscanf(const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __attribute__((__nothrow__)) __attribute__((__format__(__scanf__, 2, 0)));
extern int vfscanf(FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("""__isoc99_vfscanf") __attribute__((__format__(__scanf__, 2, 0)));
extern int vscanf(const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("""__isoc99_vscanf") __attribute__((__format__(__scanf__, 1, 0)));
extern int vsscanf(const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("""__isoc99_vsscanf") __attribute__((__nothrow__)) __attribute__((__format__(__scanf__, 2, 0)));
// RUN: %clang_cc1 %s -verify -fsyntax-only
typedef char T[4];

T foo(int n, int m) {  }  // expected-error {{cannot return array type}}

void foof(const char *, ...) __attribute__((__format__(__printf__, 1, 2))), barf (void);

int typedef validTypeDecl() { } // expected-error {{function definition declared 'typedef'}}

struct _zend_module_entry { }    // expected-error {{expected ';' after struct}}
int gv1;
typedef struct _zend_function_entry { } // expected-error {{expected ';' after struct}} \
                                        // expected-error {{declaration does not declare anything}}
int gv2;

static void buggy(int *x) { }

// Type qualifiers.
typedef int f(void); 
typedef f* fptr;
const f* v1;         // expected-warning {{qualifier on function type 'f' (aka 'int (void)') has unspecified behavior}}
__restrict__ f* v2;  // expected-error {{restrict requires a pointer or reference ('f' (aka 'int (void)') is invalid)}}
__restrict__ fptr v3; // expected-error {{pointer to function type 'f' (aka 'int (void)') may not be 'restrict' qualified}}
f *__restrict__ v4;   // expected-error {{pointer to function type 'f' (aka 'int (void)') may not be 'restrict' qualified}}

restrict struct hallo; // expected-error {{restrict requires a pointer or reference}}

// PR6180
struct test1 {
} // expected-error {{expected ';' after struct}}
示例#13
0
  printf("% s", p); // expected-warning{{flag ' ' results in undefined behavior with 's' conversion specifier}}
  printf("%0s", p); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
}

void test12(char *b) {
  unsigned char buf[4];
  printf ("%.4s\n", buf); // no-warning
  printf ("%.4s\n", &buf); // expected-warning{{conversion specifies type 'char *' but the argument has type 'unsigned char (*)[4]'}}
  
  // Verify that we are checking asprintf
  asprintf(&b, "%d", "asprintf"); // expected-warning{{conversion specifies type 'int' but the argument has type 'char *'}}
}

typedef struct __aslclient *aslclient;
typedef struct __aslmsg *aslmsg;
int asl_log(aslclient asl, aslmsg msg, int level, const char *format, ...) __attribute__((__format__ (__printf__, 4, 5)));
void test_asl(aslclient asl) {
  // Test case from <rdar://problem/7341605>.
  asl_log(asl, 0, 3, "Error: %m"); // no-warning
  asl_log(asl, 0, 3, "Error: %W"); // expected-warning{{invalid conversion specifier 'W'}}
}

// <rdar://problem/7595366>
typedef enum { A } int_t;
void f0(int_t x) { printf("%d\n", x); }

// Unicode test cases.  These are possibly specific to Mac OS X.  If so, they should
// eventually be moved into a separate test.
typedef __WCHAR_TYPE__ wchar_t;

void test_unicode_conversions(wchar_t *s) {
示例#14
0
文件: whois.c 项目: Kiichi77/MacOSX
#define	DEFAULT_PORT	"nicname"
#define	WHOIS_SERVER_ID	"Whois Server: "
#define	WHOIS_ORG_SERVER_ID	"Registrant Street1:Whois Server:"

#define WHOIS_RECURSE		0x01
#define WHOIS_QUICK		0x02

#define ishost(h) (isalnum((unsigned char)h) || h == '.' || h == '-')

const char *ip_whois[] = { LNICHOST, RNICHOST, PNICHOST, BNICHOST, NULL };
const char *port = DEFAULT_PORT;

static char *choose_server(char *);
static struct addrinfo *gethostinfo(char const *host, int exit_on_error);
#ifdef __APPLE__
static void s_asprintf(char **ret, const char *format, ...) __attribute__((__format__(printf, 2, 3)));
#else
static void s_asprintf(char **ret, const char *format, ...) __printflike(2, 3);
#endif
static void usage(void);
static void whois(const char *, const char *, int);

int
main(int argc, char *argv[])
{
	const char *country, *host;
	char *qnichost;
	int ch, flags, use_qnichost;

#ifdef	SOCKS
	SOCKSinit(argv[0]);
示例#15
0
// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks

#include <stdarg.h>

int main() {
  void (^b) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 1, 3))) =   // expected-error {{format argument not a string type}}
    ^ __attribute__ ((__format__ (__printf__, 1, 3))) (int arg, const char * format, ...) {}; // expected-error {{format argument not a string type}}
 
  void (^z) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 2, 3))) = ^ __attribute__ ((__format__ (__printf__, 2, 3))) (int arg, const char * format, ...) {};

  z(1, "%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
  z(1, "%s", "HELLO"); // no-warning
}

void multi_attr(va_list ap, int *x, long *y) {
  // Handle block with multiple format attributes.
  void (^vprintf_scanf) (const char *, va_list, const char *, ...) __attribute__((__format__(__printf__, 1, 0))) __attribute__((__format__(__scanf__, 3, 4))) =
  ^ __attribute__((__format__(__printf__, 1, 0))) __attribute__((__format__(__scanf__, 3, 4))) (const char *str, va_list args, const char *fmt, ...) {};

  vprintf_scanf("%", ap, "%d"); // expected-warning {{incomplete format specifier}}, expected-warning {{more '%' conversions than data arguments}}
}
示例#16
0
	strlcpy(msg, p, sizeof(msg));
    } else
	snprintf(msg, sizeof(msg), "Unknown error %ld", code);
    return msg;
}

KRB5_LIB_FUNCTION int KRB5_LIB_CALL
init_error_table(const char **msgs, long base, int count)
{
    initialize_error_table_r(&_et_list, msgs, count, base);
    return 0;
}

static void KRB5_CALLCONV
default_proc (const char *whoami, long code, const char *fmt, va_list args)
    __attribute__((__format__(__printf__, 3, 0)));

static void KRB5_CALLCONV
default_proc (const char *whoami, long code, const char *fmt, va_list args)
{
    if (whoami)
      fprintf(stderr, "%s: ", whoami);
    if (code)
      fprintf(stderr, "%s ", error_message(code));
    if (fmt)
      vfprintf(stderr, fmt, args);
    fprintf(stderr, "\r\n");	/* ??? */
}

static errf com_err_hook = default_proc;
示例#17
0
文件: scott.c 项目: BPaden/garglk
static int split_screen = 1;

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include <time.h>

#include "glk.h"
#include "glkstart.h"

#include "scott.h"

#ifdef __GNUC__
__attribute__((__format__(__printf__, 2, 3)))
#endif
static void wprintw(winid_t w, const char *fmt, ...)
{
	va_list ap;
	char msg[2048];

	va_start(ap, fmt);
	vsnprintf(msg, sizeof msg, fmt, ap);
	va_end(ap);

	glk_put_string_stream(glk_window_get_stream(w), msg);
}

/*
 *	Configuration Twiddles
示例#18
0
        (*type_free_fn) (type_list);
    }
    return count;
}

static inline char *
strdup_null(const char *val)
{
    if (val) {
        return strdup(val);
    }
    return NULL;
}

static void
stonith_plugin(int priority, const char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3)));

static void
stonith_plugin(int priority, const char *format, ...)
{
    int err = errno;

    va_list ap;
    int len = 0;
    char *string = NULL;

    va_start(ap, format);

    len = vasprintf (&string, format, ap);
    va_end(ap);
    CRM_ASSERT(len > 0);
示例#19
0
#define	INDENTNAMELEN	15
#define	MAXLINELEN	80

extern u_int32_t crc_total;
extern int ftsoptions;
extern int dflag, iflag, nflag, sflag;
extern u_int keys;
extern char fullpath[MAXPATHLEN];

static gid_t gid;
static uid_t uid;
static mode_t mode;

static void	output(int, int *, const char *, ...)
		    __attribute__((__format__ (printf, 3, 4)));
static int	statd(FTS *, FTSENT *, uid_t *, gid_t *, mode_t *);
static void	statf(int, FTSENT *);

void
cwalk(void)
{
	FTS *t;
	FTSENT *p;
	time_t clock;
	char *argv[2], host[MAXHOSTNAMELEN];
	int indent = 0;

	(void)time(&clock);
	(void)gethostname(host, sizeof(host));
	(void)printf(
示例#20
0
文件: attr-2.c 项目: 0day-ci/gcc
/* Origin: Joseph Myers <*****@*****.**> */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */

#define DONT_GNU_PROTOTYPE
#include "format.h"

extern void tformatprintf (const char *, ...) __attribute__((format(gnu_attr_printf, 1, 2)));
extern void tformat__printf__ (const char *, ...) __attribute__((format(gnu_attr___printf__, 1, 2)));
extern void tformatscanf (const char *, ...) __attribute__((format(gnu_attr_scanf, 1, 2)));
extern void tformat__scanf__ (const char *, ...) __attribute__((format(gnu_attr___scanf__, 1, 2)));
extern void tformatstrftime (const char *) __attribute__((format(gnu_attr_strftime, 1, 0)));
extern void tformat__strftime__ (const char *) __attribute__((format(gnu_attr___strftime__, 1, 0)));
extern void tformatstrfmon (const char *, ...) __attribute__((format(strfmon, 1, 2)));
extern void tformat__strfmon__ (const char *, ...) __attribute__((format(__strfmon__, 1, 2)));
extern void t__format__printf (const char *, ...) __attribute__((__format__(gnu_attr_printf, 1, 2)));
extern void t__format____printf__ (const char *, ...) __attribute__((__format__(gnu_attr___printf__, 1, 2)));
extern void t__format__scanf (const char *, ...) __attribute__((__format__(gnu_attr_scanf, 1, 2)));
extern void t__format____scanf__ (const char *, ...) __attribute__((__format__(gnu_attr___scanf__, 1, 2)));
extern void t__format__strftime (const char *) __attribute__((__format__(gnu_attr_strftime, 1, 0)));
extern void t__format____strftime__ (const char *) __attribute__((__format__(gnu_attr___strftime__, 1, 0)));
extern void t__format__strfmon (const char *, ...) __attribute__((__format__(strfmon, 1, 2)));
extern void t__format____strfmon__ (const char *, ...) __attribute__((__format__(__strfmon__, 1, 2)));

extern char *tformat_arg (const char *) __attribute__((format_arg(1)));
extern char *t__format_arg__ (const char *) __attribute__((__format_arg__(1)));

void
foo (int i, int *ip, double d)
{
  tformatprintf ("%d", i);
示例#21
0
/*----------------------------------------------------------------------------*\
 |                                                                            |
 |                             EXPORTED PROTOTYPES                            |
 |                                                                            |
\*----------------------------------------------------------------------------*/

int log_level_int(const char *level);
void log_params_set(int log_level_in, int log_roll_number_in, long log_max_size_bytes_in);
void log_params_get(int *log_level_out, int *log_roll_number_out, long *log_max_size_bytes_out);
int log_file_set(const char *file);
int log_prefix_set(const char *log_spec);
int log_facility_set(const char *facility, const char *component_name);
int log_sem_set(sem * s);
int logfile(const char *file, int log_level_in, int log_roll_number_in);
int logprintf(const char *format, ...) __attribute__ ((__format__(__printf__, 1, 2)));
int logprintfl(int level, const char *format, ...) __attribute__ ((__format__(__printf__, 2, 3)));
int logcat(int debug_level, const char *file_path);
void eventlog(char *hostTag, char *userTag, char *cid, char *eventTag, char *other);
void log_dump_trace(char *buf, int buf_size);

/*----------------------------------------------------------------------------*\
 |                                                                            |
 |                              STATIC PROTOTYPES                             |
 |                                                                            |
\*----------------------------------------------------------------------------*/

static FILE *get_file(boolean do_reopen);
static void release_file(void);
static int fill_timestamp(char *buf, int buf_size);
static int log_line(const char *line);
示例#22
0
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs

int (^block) (int, const char *,...) __attribute__((__format__(__printf__,2,3))) = ^ __attribute__((__format__(__printf__,2,3))) (int arg, const char *format,...) {return 5;};

class HasNoCStr {
  const char *str;
 public:
  HasNoCStr(const char *s): str(s) { }
  const char *not_c_str() {return str;}
};

void test_block() {
  const char str[] = "test";
  HasNoCStr hncs(str);
  int n = 4;
  block(n, "%s %d", str, n); // no-warning
  block(n, "%s %s", hncs, n); // expected-warning{{cannot pass non-POD object of type 'HasNoCStr' to variadic block; expected type from format string was 'char *'}} expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
}
示例#23
0
  printf("abc"
         "%*d", 1, 1); // no-warning
  printf("abc\
def"
         "%*d", 1, 1); // no-warning
         
  // <rdar://problem/6079850>, allow 'unsigned' (instead of 'int') to be used for both
  // the field width and precision.  This deviates from C99, but is reasonably safe
  // and is also accepted by GCC.
  printf("%*d", (unsigned) 1, 1); // no-warning  
}

// When calling a non-variadic format function (vprintf, vscanf, NSLogv, ...),
// warn only if the format string argument is a parameter that is not itself
// declared as a format string with compatible format.
__attribute__((__format__ (__printf__, 2, 4)))
void check_string_literal2( FILE* fp, const char* s, char *buf, ... ) {
  char * b;
  va_list ap;
  va_start(ap,buf);

  printf(s); // expected-warning {{format string is not a string literal}}
  vprintf(s,ap); // no-warning
  fprintf(fp,s); // expected-warning {{format string is not a string literal}}
  vfprintf(fp,s,ap); // no-warning
  asprintf(&b,s); // expected-warning {{format string is not a string lit}}
  vasprintf(&b,s,ap); // no-warning
  sprintf(buf,s); // expected-warning {{format string is not a string literal}}
  snprintf(buf,2,s); // expected-warning {{format string is not a string lit}}
  __builtin___vsnprintf_chk(buf,2,0,-1,s,ap); // no-warning
示例#24
0
文件: pr64223-1.c 项目: 0day-ci/gcc
/* PR c/64223: Test for duplicated warnings.  */
/* { dg-do compile } */
/* { dg-options "-Wformat" } */

int printf (const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));

void
foo (void)
{
  printf ("%d\n", 0UL); /* { dg-bogus "expects argument of type.*expects argument of type" } */
 /* { dg-warning "expects argument of type" "" { target *-*-* } 10 } */
}
示例#25
0
文件: dbtest.c 项目: OPSF/uClinux
#ifdef STATISTICS
#include "btree.h"
#endif

enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA };

#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
#define ATTR(x) __attribute__(x)
#else
#define ATTR(x)
#endif

void	 compare __P((DBT *, DBT *));
DBTYPE	 dbtype __P((char *));
void	 dump __P((DB *, int));
void	 err __P((const char *, ...)) ATTR ((__format__(__printf__,1,2))) ATTR ((__noreturn__));
void	 get __P((DB *, DBT *));
void	 getdata __P((DB *, DBT *, DBT *));
void	 put __P((DB *, DBT *, DBT *));
void	 rem __P((DB *, DBT *));
char	*sflags __P((int));
void	 synk __P((DB *));
void	*rfile __P((char *, size_t *));
void	 seq __P((DB *, DBT *));
u_int	 setflags __P((char *));
void	*setinfo __P((DBTYPE, char *));
void	 usage __P((void));
void	*xmalloc __P((char *, size_t));

DBTYPE type;				/* Database type. */
void *infop;				/* Iflags. */
示例#26
0
文件: mrr.c 项目: naver/arcus-misc
  log_msg( __VA_ARGS__);                            \
  printf("die %s:%d\n", __FILE__, __LINE__);        \
  exit(1);                                          \
} while(0)

#define PERROR_DIE(...) do {                                                \
  log_msg( __VA_ARGS__);                                                    \
  printf("%s(%d) die %s:%d\n", strerror(errno), errno, __FILE__, __LINE__); \
  exit(1);                                                                  \
} while(0)

void parse_args(int argc, char *argv[]);
void usage(void);
int filladdr(char *host, struct sockaddr_in *addr);
void log_msg(const char *fmt, ...)
  __attribute__ ((__format__ (__printf__, 1, 2)));

// latency histogram
// 40 bins x 20 msec = 800 msec
#define HIST_BIN_COUNT 40
#define HIST_BIN_WIDTH 20
struct hist {
  uint32_t bin[HIST_BIN_COUNT];
};

static void
hist_inc(struct hist *h, uint32_t val)
{
  uint32_t i = val / HIST_BIN_WIDTH;
  if (i >= HIST_BIN_COUNT)
    i = HIST_BIN_COUNT-1;
示例#27
0
#include <portable/system.h>

#include <tests/tap/macros.h>
#include <tests/tap/messages.h>
#include <tests/tap/string.h>
#include <util/messages.h>

/* A global buffer into which message_log_buffer stores error messages. */
char *errors = NULL;


/*
 * An error handler that appends all errors to the errors global.  Used by
 * error_capture.
 */
static void __attribute__((__format__(printf, 2, 0)))
message_log_buffer(int len UNUSED, const char *fmt, va_list args,
                   int error UNUSED)
{
    char *message;

    bvasprintf(&message, fmt, args);
    if (errors == NULL)
        basprintf(&errors, "%s\n", message);
    else {
        char *new_errors;

        basprintf(&new_errors, "%s%s\n", errors, message);
        free(errors);
        errors = new_errors;
    }
示例#28
0
文件: asprintf.c 项目: mloar/remctl
 * copying, publishing, distributing or creating derivative works of this
 * work.
 */

#include <config.h>
#include <portable/system.h>

/*
 * If we're running the test suite, rename the functions to avoid conflicts
 * with the system versions.
 */
#if TESTING
# define asprintf test_asprintf
# define vasprintf test_vasprintf
int test_asprintf(char **, const char *, ...)
__attribute__((__format__(printf, 2, 3)));
int test_vasprintf(char **, const char *, va_list);
#endif

int
asprintf(char **strp, const char *fmt, ...)
{
    va_list args;
    int status;

    va_start(args, fmt);
    status = vasprintf(strp, fmt, args);
    va_end(args);
    return status;
}
示例#29
0
文件: error.c 项目: OSLL/elfperf
/* This variable is incremented each time `error' is called.  */
unsigned int error_message_count;

#ifdef _LIBC
/* In the GNU C library, there is a predefined variable for this.  */

# define program_name program_invocation_name
# include <errno.h>
# include <limits.h>
# include <libio/libioP.h>

/* In GNU libc we want do not want to use the common name `error' directly.
   Instead make it a weak alias.  */
extern void __error (int status, int errnum, const char *message, ...)
     __attribute__ ((__format__ (__printf__, 3, 4)));
extern void __error_at_line (int status, int errnum, const char *file_name,
			     unsigned int line_number, const char *message,
			     ...)
     __attribute__ ((__format__ (__printf__, 5, 6)));;
# define error __error
# define error_at_line __error_at_line

# include <libio/iolibio.h>
# define fflush(s) INTUSE(_IO_fflush) (s)
# undef putc
# define putc(c, fp) INTUSE(_IO_putc) (c, fp)

# include <bits/libc-lock.h>

#else /* not _LIBC */
示例#30
0
/** Extra warnings: standard warnings plus others */
#define W_EXTRA         (W_NORMAL|W_THING_MSGS)
/** All warnings */
#define W_ALL           (W_EXTRA|W_EXIT_DESC)


/** A structure representing a topology warning check. */
typedef struct a_tcheck {
  const char *name;     /**< Name of warning. */
  warn_type flag;       /**< Bitmask of warning. */
} tcheck;


extern int warning_lock_type(const boolexp l);
void complain(dbref player, dbref i, const char *name, const char *desc, ...)
  __attribute__ ((__format__(__printf__, 4, 5)));
extern void check_lock(dbref player, dbref i, const char *name, boolexp be);
static void ct_generic(dbref player, dbref i, warn_type flags);
static void ct_room(dbref player, dbref i, warn_type flags);
static void ct_exit(dbref player, dbref i, warn_type flags);
static void ct_player(dbref player, dbref i, warn_type flags);
static void ct_thing(dbref player, dbref i, warn_type flags);


static tcheck checklist[] = {
  {"none", W_NONE},             /* MUST BE FIRST! */
  {"exit-unlinked", W_EXIT_UNLINKED},
  {"thing-desc", W_THING_DESC},
  {"room-desc", W_ROOM_DESC},
  {"my-desc", W_PLAYER_DESC},
  {"exit-oneway", W_EXIT_ONEWAY},