]> err.no Git - varnish/commitdiff
Make vsb_new() a tad easier for FlexeLint to figure out.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 21 Dec 2008 18:41:43 +0000 (18:41 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 21 Dec 2008 18:41:43 +0000 (18:41 +0000)
Give it proper semantics

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3496 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/flint.lnt
varnish-cache/lib/libvarnish/vsb.c

index f27ed57d9ae0532f22141fe704becd72784cab95..492c71b143be7a3f004412f2c5902f362003e7c8 100644 (file)
 -emacro(702, WEXITSTATUS)      // signed shift right 
 -efunc(525, VCC_Return_Name)   // Negative indent
 
-
 // -header(../../config.h)
 
 // Fix strchr() semtics, it can only return NULL if arg2 != 0
 -sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 ))
 
--sem(vsb_new, @p == malloc(1))
+-sem(vsb_new, @p == (1p ? 1p : malloc(1)))
 -sem(vsb_delete, custodial(1))
 -sem(lbv_assert, r_no)
 -sem(lbv_xxxassert, r_no)
index 16af1371979336f6152022a7008908fb2d99a8c3..af9f1701b5f4daf801b15a1e96ea6f2daf705048 100644 (file)
@@ -162,15 +162,17 @@ vsb_new(struct vsb *s, char *buf, int length, int flags)
                s = (struct vsb *)SBMALLOC(sizeof *s);
                if (s == NULL)
                        return (NULL);
-               memset(s, 0, sizeof *s);
-               s->s_flags = flags;
-               s->s_magic = VSB_MAGIC;
+               if (vsb_new(s, buf, length, flags) == NULL) {
+                       free(s);
+                       return (NULL);
+               }
                VSB_SETFLAG(s, VSB_DYNSTRUCT);
-       } else {
-               memset(s, 0, sizeof *s);
-               s->s_flags = flags;
-               s->s_magic = VSB_MAGIC;
+               return (s);
        }
+
+       memset(s, 0, sizeof *s);
+       s->s_flags = flags;
+       s->s_magic = VSB_MAGIC;
        s->s_size = length;
        if (buf) {
                s->s_buf = buf;
@@ -179,11 +181,8 @@ vsb_new(struct vsb *s, char *buf, int length, int flags)
        if (flags & VSB_AUTOEXTEND)
                s->s_size = vsb_extendsize(s->s_size);
        s->s_buf = (char *)SBMALLOC(s->s_size);
-       if (s->s_buf == NULL) {
-               if (VSB_ISDYNSTRUCT(s))
-                       SBFREE(s);
+       if (s->s_buf == NULL)
                return (NULL);
-       }
        VSB_SETFLAG(s, VSB_DYNAMIC);
        return (s);
 }