Author: metze
Date: 2007-01-19 12:22:30 +0000 (Fri, 19 Jan 2007)
New Revision: 20901

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20901

Log:
- not all compiler like uint8_t data[0] elements!
- this fix looks really ugly but I don't know a better solution...

if we would use uint8_t *data; then we would send the pointer value
also in the network packet and we would need to initialize

s->data = ((void *)(&s->data) + 1;

to make the memcpy statements work as they're currently,
so we use uint8_t data[1] in the struct definition ...

tridge: please review careful!

hopefully fix the build on solaris and HPUX

metze
Modified:
   branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c
   branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h


Changeset:
Modified: branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c   2007-01-19 
12:16:39 UTC (rev 20900)
+++ branches/SAMBA_4_0/source/cluster/ctdb/common/ctdb_call.c   2007-01-19 
12:22:30 UTC (rev 20901)
@@ -135,9 +135,9 @@
        va_end(ap);
 
        len = strlen(msg)+1;
-       r = ctdb->methods->allocate_pkt(ctdb, sizeof(*r) + len);
+       r = ctdb->methods->allocate_pkt(ctdb, sizeof(*r) - 1 + len);
        CTDB_NO_MEMORY_FATAL(ctdb, r);
-       r->hdr.length = sizeof(*r) + len;
+       r->hdr.length = sizeof(*r) - 1 + len;
        r->hdr.operation = CTDB_REPLY_ERROR;
        r->hdr.destnode  = hdr->srcnode;
        r->hdr.srcnode   = ctdb->vnn;
@@ -192,7 +192,7 @@
        struct ctdb_req_dmaster *r;
        int len;
        
-       len = sizeof(*r) + key->dsize + data->dsize;
+       len = sizeof(*r) - 1 + key->dsize + data->dsize;
        r = ctdb->methods->allocate_pkt(ctdb, len);
        CTDB_NO_MEMORY_FATAL(ctdb, r);
        r->hdr.length    = len;
@@ -281,9 +281,9 @@
        }
 
        /* send the CTDB_REPLY_DMASTER */
-       r = ctdb->methods->allocate_pkt(ctdb, sizeof(*r) + data.dsize);
+       r = ctdb->methods->allocate_pkt(ctdb, sizeof(*r) - 1 + data.dsize);
        CTDB_NO_MEMORY_FATAL(ctdb, r);
-       r->hdr.length = sizeof(*r) + data.dsize;
+       r->hdr.length = sizeof(*r) - 1 + data.dsize;
        r->hdr.operation = CTDB_REPLY_DMASTER;
        r->hdr.destnode  = c->dmaster;
        r->hdr.srcnode   = ctdb->vnn;
@@ -358,9 +358,9 @@
                        call_data.dsize?&call_data:NULL,
                        &reply_data, c->hdr.srcnode);
 
-       r = ctdb->methods->allocate_pkt(ctdb, sizeof(*r) + reply_data.dsize);
+       r = ctdb->methods->allocate_pkt(ctdb, sizeof(*r) - 1 + 
reply_data.dsize);
        CTDB_NO_MEMORY_FATAL(ctdb, r);
-       r->hdr.length = sizeof(*r) + reply_data.dsize;
+       r->hdr.length = sizeof(*r) - 1 + reply_data.dsize;
        r->hdr.operation = CTDB_REPLY_CALL;
        r->hdr.destnode  = hdr->srcnode;
        r->hdr.srcnode   = hdr->destnode;
@@ -580,7 +580,7 @@
        state = talloc_zero(ctdb, struct ctdb_call_state);
        CTDB_NO_MEMORY_NULL(ctdb, state);
 
-       len = sizeof(*state->c) + key.dsize + (call_data?call_data->dsize:0);
+       len = sizeof(*state->c) - 1 + key.dsize + 
(call_data?call_data->dsize:0);
        state->c = ctdb->methods->allocate_pkt(ctdb, len);
        CTDB_NO_MEMORY_NULL(ctdb, state->c);
 

Modified: branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h
===================================================================
--- branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h       
2007-01-19 12:16:39 UTC (rev 20900)
+++ branches/SAMBA_4_0/source/cluster/ctdb/include/ctdb_private.h       
2007-01-19 12:22:30 UTC (rev 20901)
@@ -157,20 +157,20 @@
        uint32_t callid;
        uint32_t keylen;
        uint32_t calldatalen;
-       uint8_t data[0]; /* key[] followed by calldata[] */
+       uint8_t data[1]; /* key[] followed by calldata[] */
 };
 
 struct ctdb_reply_call {
        struct ctdb_req_header hdr;
        uint32_t datalen;
-       uint8_t  data[0];
+       uint8_t  data[1];
 };
 
 struct ctdb_reply_error {
        struct ctdb_req_header hdr;
        uint32_t status;
        uint32_t msglen;
-       uint8_t  msg[0];
+       uint8_t  msg[1];
 };
 
 struct ctdb_reply_redirect {
@@ -183,13 +183,13 @@
        uint32_t dmaster;
        uint32_t keylen;
        uint32_t datalen;
-       uint8_t  data[0];
+       uint8_t  data[1];
 };
 
 struct ctdb_reply_dmaster {
        struct ctdb_req_header hdr;
        uint32_t datalen;
-       uint8_t  data[0];
+       uint8_t  data[1];
 };
 
 /* internal prototypes */

Reply via email to