Changeset d0be5a


Ignore:
Timestamp:
2012-01-15 18:14:51 (2 years ago)
Author:
Rogier 'DocWilco' Mulhuijzen <github@…>
Branches:
master, 4.0, experimental-ims
Children:
5b8d89
Parents:
3eea8da
git-author:
Rogier 'DocWilco' Mulhuijzen <github@…> (2012-01-15 17:37:03)
git-committer:
Rogier 'DocWilco' Mulhuijzen <github@…> (2012-01-15 18:14:51)
Message:

Add printflike and fix everything that brings to light

Files:
27 edited

Legend:

Unmodified
Added
Removed
  • bin/varnishd/cache/cache.h

    r8a37b31 rd0be5a  
    810810    const char *response); 
    811811void http_PrintfHeader(struct worker *w, unsigned vsl_id, struct http *to, 
    812     const char *fmt, ...); 
     812    const char *fmt, ...) 
     813    __printflike(4, 5); 
    813814void http_SetHeader(struct worker *w, unsigned vsl_id, struct http *to, 
    814815    const char *hdr); 
     
    929930void VSM_Free(void *ptr); 
    930931#ifdef VSL_ENDMARKER 
    931 void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...); 
     932void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) 
     933    __printflike(3, 4); 
    932934void WSLR(struct worker *w, enum VSL_tag_e tag, int id, txt t); 
    933 void WSL(struct worker *w, enum VSL_tag_e tag, int id, const char *fmt, ...); 
    934 void WSLB(struct worker *w, enum VSL_tag_e tag, const char *fmt, ...); 
     935void WSL(struct worker *w, enum VSL_tag_e tag, int id, const char *fmt, ...) 
     936    __printflike(4, 5); 
     937void WSLB(struct worker *w, enum VSL_tag_e tag, const char *fmt, ...) 
     938    __printflike(3, 4); 
    935939 
    936940void WSL_Flush(struct worker *w, int overflow); 
  • bin/varnishd/cache/cache_center.c

    r3eea8da rd0be5a  
    17771777        srandom(seed); 
    17781778        srand48(random()); 
    1779         VCLI_Out(cli, "Random(3) seeded with %lu", seed); 
     1779        VCLI_Out(cli, "Random(3) seeded with %u", seed); 
    17801780} 
    17811781 
  • bin/varnishd/cache/cache_shmlog.c

    r41608b rd0be5a  
    237237static void 
    238238wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) 
     239    __printflike(4, 0); 
     240 
     241static void 
     242wsl(struct worker *wrk, enum VSL_tag_e tag, int id, const char *fmt, va_list ap) 
    239243{ 
    240244        char *p; 
  • bin/varnishd/cache/cache_vrt_vmod.c

    rf3a414 rd0be5a  
    105105                if (strcmp(x, nm)) { 
    106106                        VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path); 
    107                         VCLI_Out(cli, "File contain wrong VMOD (\"%s\")\n", x); 
     107                        VCLI_Out(cli, "File contain wrong VMOD (\"%s\")\n", 
     108                            (char *) x); 
    108109                        VCLI_Out(cli, "Check relative pathnames ?.\n"); 
    109110                        (void)dlclose(v->hdl); 
  • bin/varnishd/mgt/mgt.h

    r28af71 rd0be5a  
    5151void mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, 
    5252    mgt_cli_close_f *close_func, void *priv); 
    53 int mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...); 
     53int mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) 
     54    __printflike(3, 4); 
    5455void mgt_cli_start_child(int fdi, int fdo); 
    5556void mgt_cli_stop_child(void); 
  • bin/varnishd/mgt/mgt_param.c

    rff61fc rd0be5a  
    262262                *dest = u; 
    263263        } else if (*dest == UINT_MAX) { 
    264                 VCLI_Out(cli, "unlimited", *dest); 
     264                VCLI_Out(cli, "unlimited"); 
    265265        } else { 
    266266                VCLI_Out(cli, "%u", *dest); 
  • bin/varnishreplay/varnishreplay.c

    ra8aa0b rd0be5a  
    4545#include <unistd.h> 
    4646 
     47#include "vdef.h" 
    4748#include "vapi/vsl.h" 
    4849#include "vapi/vsm.h" 
     
    169170 
    170171static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; 
     172 
     173static void 
     174thread_log(int lvl, int errcode, const char *fmt, ...) 
     175    __printflike(3, 4); 
    171176 
    172177static void 
  • bin/varnishtest/vtc.c

    radf381c rd0be5a  
    450450                if (l == random_expect[i]) 
    451451                        continue; 
    452                 vtc_log(vl, 4, "random[%d] = 0x%x (expect 0x%x)", 
     452                vtc_log(vl, 4, "random[%d] = 0x%x (expect 0x%lx)", 
    453453                    i, l, random_expect[i]); 
    454454                vtc_log(vl, 1, "SKIPPING test: unknown srandom(1) sequence."); 
     
    539539        /* Apply extmacro definitions */ 
    540540        VTAILQ_FOREACH(m, &extmacro_list, list) 
    541                 macro_def(vltop, NULL, m->name, m->val); 
     541                macro_def(vltop, NULL, m->name, "%s", m->val); 
    542542 
    543543        /* Other macro definitions */ 
    544544        cwd = getcwd(NULL, PATH_MAX); 
    545         macro_def(vltop, NULL, "pwd", cwd); 
     545        macro_def(vltop, NULL, "pwd", "%s", cwd); 
    546546        macro_def(vltop, NULL, "topbuild", "%s/%s", cwd, TOP_BUILDDIR); 
    547547        macro_def(vltop, NULL, "bad_ip", "10.255.255.255"); 
     
    549549        /* Move into our tmpdir */ 
    550550        AZ(chdir(tmpdir)); 
    551         macro_def(vltop, NULL, "tmpdir", tmpdir); 
     551        macro_def(vltop, NULL, "tmpdir", "%s", tmpdir); 
    552552 
    553553        /* Drop file to tell what was going on here */ 
  • bin/varnishtest/vtc.h

    r1ff8836 rd0be5a  
    7878struct vtclog *vtc_logopen(const char *id); 
    7979void vtc_logclose(struct vtclog *vl); 
    80 void vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...); 
     80void vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...) 
     81    __printflike(3, 4); 
    8182void vtc_dump(struct vtclog *vl, int lvl, const char *pfx, 
    8283    const char *str, int len); 
     
    8889 
    8990void macro_def(struct vtclog *vl, const char *instance, const char *name, 
    90     const char *fmt, ...); 
     91    const char *fmt, ...) 
     92    __printflike(4, 5); 
    9193struct vsb *macro_expand(struct vtclog *vl, const char *text); 
    9294 
    93 void extmacro_def(const char *name, const char *fmt, ...); 
     95void extmacro_def(const char *name, const char *fmt, ...) 
     96    __printflike(2, 3); 
  • bin/varnishtest/vtc_http.c

    rc4629a rd0be5a  
    134134http_write(const struct http *hp, int lvl, const char *pfx) 
    135135{ 
    136         int l; 
     136        ssize_t l; 
    137137 
    138138        AZ(VSB_finish(hp->vsb)); 
     
    140140        l = write(hp->fd, VSB_data(hp->vsb), VSB_len(hp->vsb)); 
    141141        if (l != VSB_len(hp->vsb)) 
    142                 vtc_log(hp->vl, hp->fatal, "Write failed: (%d vs %d) %s", 
     142                vtc_log(hp->vl, hp->fatal, "Write failed: (%zd vs %zd) %s", 
    143143                    l, VSB_len(hp->vsb), strerror(errno)); 
    144144} 
     
    388388        if ((q == hp->rxbuf + l) || 
    389389                (*q != '\0' && !vct_islws(*q))) { 
    390                 vtc_log(hp->vl, hp->fatal, "chunked fail %02x @ %d", 
     390                vtc_log(hp->vl, hp->fatal, "chunked fail %02x @ %td", 
    391391                    *q, q - (hp->rxbuf + l)); 
    392392        } 
  • bin/varnishtest/vtc_sema.c

    r8aa1d8 rd0be5a  
    6464        r->name = name; 
    6565        if (*name != 'r') 
    66                 vtc_log(vl, 0, "Sema name must start with 'r' (%s)", *name); 
     66                vtc_log(vl, 0, "Sema name must start with 'r' (%s)", name); 
    6767 
    6868        AZ(pthread_mutex_init(&r->mtx, NULL)); 
  • include/vcli_common.h

    rccf9f8 rd0be5a  
    2929 */ 
    3030 
     31#include "vdef.h" 
     32 
    3133struct vlu; 
    3234struct VCLS; 
  • include/vcli_priv.h

    r985791 rd0be5a  
    5454/* The implementation must provide these functions */ 
    5555int VCLI_Overflow(struct cli *cli); 
    56 void VCLI_Out(struct cli *cli, const char *fmt, ...); 
     56void VCLI_Out(struct cli *cli, const char *fmt, ...) 
     57    __printflike(2, 3); 
    5758void VCLI_Quote(struct cli *cli, const char *str); 
    5859void VCLI_SetResult(struct cli *cli, unsigned r); 
  • include/vdef.h

    ra88956 rd0be5a  
    11/*- 
    22 * Copyright (c) 2006 Verdens Gang AS 
    3  * Copyright (c) 2006-2011 Varnish Software AS 
     3 * Copyright (c) 2006-2012 Varnish Software AS 
     4 * Copyright (c) 2012 Fastly Inc 
    45 * All rights reserved. 
    56 * 
    67 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk> 
     8 * Author: Rogier 'DocWilco' Mulhuijzen <rogier@fastly.com> 
    79 * 
     10 * Inspired by FreeBSD's <sys/cdefs.h> 
     11 *  
    812 * Redistribution and use in source and binary forms, with or without 
    913 * modification, are permitted provided that the following conditions 
     
    2933 */ 
    3034 
     35#ifndef VDEF_H_INCLUDED 
     36#define VDEF_H_INCLUDED 
     37 
    3138/* Safe printf into a fixed-size buffer */ 
    3239#define bprintf(buf, fmt, ...)                                          \ 
     
    4350        } while (0) 
    4451 
     52 
     53#ifndef __GNUC_PREREQ 
     54# if defined __GNUC__ && defined __GNUC_MINOR__ 
     55#  define __GNUC_PREREQ(maj, min) \ 
     56        (__GNUC__ > (maj) || (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min))) 
     57# else 
     58#  define __GNUC_PREREQ(maj, min) 0 
     59# endif 
     60#endif 
     61 
     62#ifndef __printflike 
     63# if __GNUC_PREREQ(2, 95) || defined(__INTEL_COMPILER) 
     64#  define __printflike(f,a) __attribute__((format(printf, f, a))) 
     65# else 
     66#  define __printflike(f,a) 
     67# endif 
     68#endif 
     69 
     70#endif /* VDEF_H_INCLUDED */ 
  • include/vsb.h

    r8aa1d8 rd0be5a  
    3232#define VSB_H_INCLUDED 
    3333 
     34#include "vdef.h" 
     35 
    3436/* 
    3537 * Structure definition 
     
    4951        int              s_flags;       /* flags */ 
    5052}; 
    51  
    52 #ifndef __printflike 
    53 #define __printflike(a,b) 
    54 #endif 
    5553 
    5654#ifdef __cplusplus 
  • lib/libvarnishapi/vsc.c

    r28af71 rd0be5a  
    4040#include "miniobj.h" 
    4141#include "vas.h" 
     42#include "vdef.h" 
    4243 
    4344#include "vapi/vsc.h" 
  • lib/libvarnishapi/vsl.c

    rf4ba8e rd0be5a  
    4242#include "miniobj.h" 
    4343#include "vas.h" 
     44#include "vdef.h" 
    4445 
    4546#include "vapi/vsl.h" 
  • lib/libvarnishapi/vsl_arg.c

    ra8aa0b rd0be5a  
    4444#include "miniobj.h" 
    4545#include "vas.h" 
     46#include "vdef.h" 
    4647 
    4748#include "vapi/vsl.h" 
  • lib/libvarnishapi/vsm.c

    r6b8419 rd0be5a  
    4545#include "miniobj.h" 
    4646#include "vas.h" 
     47#include "vdef.h" 
    4748 
    4849#include "vapi/vsm.h" 
  • lib/libvarnishapi/vsm_api.h

    r5a7a85 rd0be5a  
    5252}; 
    5353 
    54 int vsm_diag(struct VSM_data *vd, const char *fmt, ...); 
     54int vsm_diag(struct VSM_data *vd, const char *fmt, ...) 
     55    __printflike(2, 3); 
    5556void VSC_Delete(struct VSM_data *vd); 
    5657void VSL_Delete(struct VSM_data *vd); 
  • lib/libvcl/vcc_acl.c

    r8aa1d8 rd0be5a  
    363363        Fh(tl, 0, "\n"); 
    364364        Fh(tl, 0, "\ta = p;\n"); 
    365         Fh(tl, 0, "\tVRT_memmove(&fam, a + %d, sizeof fam);\n", 
     365        Fh(tl, 0, "\tVRT_memmove(&fam, a + %zd, sizeof fam);\n", 
    366366            offsetof(struct sockaddr, sa_family)); 
    367367        Fh(tl, 0, "\tif (fam == %d)\n", PF_INET); 
    368         Fh(tl, 0, "\t\ta += %d;\n", offsetof(struct sockaddr_in, sin_addr)); 
     368        Fh(tl, 0, "\t\ta += %zd;\n", offsetof(struct sockaddr_in, sin_addr)); 
    369369        Fh(tl, 0, "\telse if (fam == %d)\n", PF_INET6); 
    370         Fh(tl, 0, "\t\ta += %d;\n", offsetof(struct sockaddr_in6, sin6_addr)); 
     370        Fh(tl, 0, "\t\ta += %zd;\n", offsetof(struct sockaddr_in6, sin6_addr)); 
    371371        Fh(tl, 0, "\telse {\n"); 
    372372        Fh(tl, 0, "\t\tVRT_acl_log(sp, \"NO_FAM %s\");\n", acln); 
     
    423423                if (!anon) { 
    424424                        Fh(tl, 0, "\t%*sVRT_acl_log(sp, \"%sMATCH %s \" ", 
    425                             -i, "", ae->not ? "NEG_" : "", acln, 
    426                             PF(ae->t_addr)); 
     425                            -i, "", ae->not ? "NEG_" : "", acln); 
    427426                        EncToken(tl->fh, ae->t_addr); 
    428427                        if (ae->t_mask != NULL) 
  • lib/libvcl/vcc_backend.c

    r8aa1d8 rd0be5a  
    354354                Fh(tl, 0, "\t.initial = %u,\n", initial); 
    355355        else 
    356                 Fh(tl, 0, "\t.initial = ~0U,\n", initial); 
     356                Fh(tl, 0, "\t.initial = ~0U,\n"); 
    357357        if (status > 0) 
    358358                Fh(tl, 0, "\t.exp_status = %u,\n", status); 
  • lib/libvcl/vcc_compile.c

    r6bec2c rd0be5a  
    287287 
    288288                } 
    289                 Fc(tl, 0, "  [%3u] = { %d, %8u, %4u, %3u, 0, ", 
     289                Fc(tl, 0, "  [%3u] = { %d, %8tu, %4u, %3u, 0, ", 
    290290                    t->cnt, sp->idx, t->b - sp->b, lin, pos + 1); 
    291291                if (t->tok == CSRC) 
  • lib/libvcl/vcc_compile.h

    r28af71 rd0be5a  
    248248 * F -> Finish function 
    249249 */ 
    250 void Fh(const struct vcc *tl, int indent, const char *fmt, ...); 
    251 void Fc(const struct vcc *tl, int indent, const char *fmt, ...); 
    252 void Fb(const struct vcc *tl, int indent, const char *fmt, ...); 
    253 void Fi(const struct vcc *tl, int indent, const char *fmt, ...); 
    254 void Ff(const struct vcc *tl, int indent, const char *fmt, ...); 
     250void Fh(const struct vcc *tl, int indent, const char *fmt, ...) 
     251    __printflike(3, 4); 
     252void Fc(const struct vcc *tl, int indent, const char *fmt, ...) 
     253    __printflike(3, 4); 
     254void Fb(const struct vcc *tl, int indent, const char *fmt, ...) 
     255    __printflike(3, 4); 
     256void Fi(const struct vcc *tl, int indent, const char *fmt, ...) 
     257    __printflike(3, 4); 
     258void Ff(const struct vcc *tl, int indent, const char *fmt, ...) 
     259    __printflike(3, 4); 
    255260void EncToken(struct vsb *sb, const struct token *t); 
    256261int IsMethod(const struct token *t); 
  • lib/libvcl/vcc_dir_dns.c

    r872c47 rd0be5a  
    9393        Fb(tl, 0, "\t.hosthdr = \""); 
    9494        if (b_defaults.hostheader != NULL) 
    95                 Fb(tl,0, b_defaults.hostheader); 
     95                Fb(tl, 0, "%s", b_defaults.hostheader); 
    9696        else 
    97                 Fb(tl,0, strip); 
     97                Fb(tl, 0, "%s", strip); 
    9898        Fb(tl, 0, "\",\n"); 
    9999 
  • lib/libvcl/vcc_expr.c

    r8aa1d8 rd0be5a  
    254254static struct expr * 
    255255vcc_mk_expr(enum var_type fmt, const char *str, ...) 
     256    __printflike(2, 3); 
     257 
     258static struct expr * 
     259vcc_mk_expr(enum var_type fmt, const char *str, ...) 
    256260{ 
    257261        va_list ap; 
     
    538542                        AN(r); 
    539543                        e1 = vcc_mk_expr(VOID, "&vmod_priv_%.*s", 
    540                             r - sym->name, sym->name); 
     544                            (int) (r - sym->name), sym->name); 
    541545                        p += strlen(p) + 1; 
    542546                } else if (fmt == VOID && !strcmp(p, "PRIV_CALL")) { 
  • lib/libvcl/vcc_parse.c

    rc5c9e33 rd0be5a  
    155155                case CSRC: 
    156156                        Fb(tl, 1, "%.*s\n", 
    157                             tl->t->e - (tl->t->b + 2), 
     157                            (int) (tl->t->e - (tl->t->b + 2)), 
    158158                            tl->t->b + 1); 
    159159                        vcc_NextToken(tl); 
     
    275275                case CSRC: 
    276276                        Fc(tl, 0, "%.*s\n", 
    277                             tl->t->e - (tl->t->b + 4), tl->t->b + 2); 
     277                            (int) (tl->t->e - (tl->t->b + 4)), tl->t->b + 2); 
    278278                        vcc_NextToken(tl); 
    279279                        break; 
Note: See TracChangeset for help on using the changeset viewer.