r14288: - make the snprintf call in talloc portable to older solaris boxes
authorAndrew Tridgell <tridge@samba.org>
Mon, 13 Mar 2006 04:04:38 +0000 (04:04 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:57:08 +0000 (13:57 -0500)
 - fixed an error found sing the beam analyser
(This used to be commit bc45451ddd6eceb9bf1ca02f84932759d99a1744)

source4/lib/talloc/talloc.c

index 5bb21ee6e6bf1a73cc765ebd4c5ce4a18dc1345a..99ede462b8e8eb9432a75538628a3aea317ffa74 100644 (file)
@@ -293,7 +293,11 @@ static int talloc_unreference(const void *context, const void *ptr)
 
        for (h=tc->refs;h;h=h->next) {
                struct talloc_chunk *p = talloc_parent_chunk(h);
-               if ((p==NULL && context==NULL) || TC_PTR_FROM_CHUNK(p) == context) break;
+               if (p == NULL) {
+                       if (context == NULL) break;
+               } else if (TC_PTR_FROM_CHUNK(p) == context) {
+                       break;
+               }
        }
        if (h == NULL) {
                return -1;
@@ -1010,10 +1014,12 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
        int len;
        char *ret;
        va_list ap2;
+       char c;
        
        VA_COPY(ap2, ap);
 
-       if ((len = vsnprintf(NULL, 0, fmt, ap2)) < 0) {
+       /* this call looks strange, but it makes it work on older solaris boxes */
+       if ((len = vsnprintf(&c, 1, fmt, ap2)) < 0) {
                return NULL;
        }