OSSP CVS Repository

ossp - Check-in [4368]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4368
Date: 2004-Jan-18 20:22:54 (local)
2004-Jan-18 19:22:54 (UTC)
User:rse
Branch:
Comment: - Cleanup the C code to also pass warning-free a C++ compiler. - Support C++ by enclosing the C API declarations in 'extern "C" {...}' within uuid.h.

Submitted by: Guerry Semones <guerry@tsunamiresearch.com>

Tickets:
Inspections:
Files:
ossp-pkg/uuid/ChangeLog      1.25 -> 1.26     7 inserted, 0 deleted
ossp-pkg/uuid/uuid.c      1.34 -> 1.35     5 inserted, 5 deleted
ossp-pkg/uuid/uuid.h      1.11 -> 1.12     13 inserted, 0 deleted
ossp-pkg/uuid/uuid_md5.c      1.4 -> 1.5     3 inserted, 3 deleted
ossp-pkg/uuid/uuid_prng.c      1.1 -> 1.2     2 inserted, 2 deleted
ossp-pkg/uuid/uuid_str.c      1.1 -> 1.2     3 inserted, 3 deleted
ossp-pkg/uuid/uuid_ui64.c      1.1 -> 1.2     1 inserted, 1 deleted

ossp-pkg/uuid/ChangeLog 1.25 -> 1.26

--- ChangeLog    2004/01/18 11:31:09     1.25
+++ ChangeLog    2004/01/18 19:22:54     1.26
@@ -13,6 +13,13 @@
 
   Changes between 0.9.3 and 0.9.4 (16-Jan-2004 to xx-Jan-2004)
 
+   o Cleanup the C code to also pass warning-free a C++ compiler.
+     [Ralf S. Engelschall]
+
+   o Support C++ by enclosing the C API declarations in
+     'extern "C" {...}' within uuid.h.
+     [Guerry Semones <guerry@tsunamiresearch.com>]
+
    o Improvide decoding in uuid_dump() by at least hex-dumping the
      binary representation in case of v3, v4 and Nil UUIDs. Also,
      annotate with better hints.


ossp-pkg/uuid/uuid.c 1.34 -> 1.35

--- uuid.c       2004/01/18 11:31:10     1.34
+++ uuid.c       2004/01/18 19:22:54     1.35
@@ -218,7 +218,7 @@
     const uuid_uint8_t *in;
     uuid_uint32_t tmp32;
     uuid_uint16_t tmp16;
-    int i;
+    unsigned int i;
 
     /* sanity check argument(s) */
     if (uuid == NULL || buf == NULL)
@@ -264,7 +264,7 @@
     uuid_uint8_t *out;
     uuid_uint32_t tmp32;
     uuid_uint16_t tmp16;
-    int i;
+    unsigned int i;
 
     /* sanity check argument(s) */
     if (uuid == NULL || buf == NULL)
@@ -343,7 +343,7 @@
     uuid_uint16_t tmp16;
     const char *cp;
     char hexbuf[3];
-    int i;
+    unsigned int i;
 
     /* sanity check argument(s) */
     if (uuid == NULL || str == NULL)
@@ -649,7 +649,7 @@
     void *uuid_octets;
     uuid_t *uuid_object;
     uuid_rc_t rc;
-    int i;
+    unsigned int i;
 
     /* determine namespace UUID name and argument name string */
     if ((ns = (char *)va_arg(ap, char *)) == NULL)
@@ -774,7 +774,7 @@
     uuid_uint32_t tmp32;
     char string[UUID_LEN_STR+1];
     char *s;
-    int i;
+    unsigned int i;
     ui64_t t;
     ui64_t offset;
     int t_nsec;


ossp-pkg/uuid/uuid.h 1.11 -> 1.12

--- uuid.h       2004/01/15 12:32:26     1.11
+++ uuid.h       2004/01/18 19:22:54     1.12
@@ -30,6 +30,17 @@
 #ifndef __UUID_H__
 #define __UUID_H__
 
+/* minimum C++ support */
+#ifdef __cplusplus
+#define DECLARATION_BEGIN extern "C" {
+#define DECLARATION_END   }
+#else
+#define DECLARATION_BEGIN /*nop*/
+#define DECLARATION_END   /*nop*/
+#endif
+
+DECLARATION_BEGIN
+
 /* encoding octet stream lengths */
 #define UUID_LEN_BIN (128 / 8 /*bytes*/)
 #define UUID_LEN_STR (128 / 4 /*nibbles*/ + 4 /*hyphens*/)
@@ -79,5 +90,7 @@
 /* error handling */
 extern char      *uuid_error    (uuid_rc_t _rc);
 
+DECLARATION_END
+
 #endif /* __UUID_H__ */
 


ossp-pkg/uuid/uuid_md5.c 1.4 -> 1.5

--- uuid_md5.c   2004/01/10 12:16:03     1.4
+++ uuid_md5.c   2004/01/18 19:22:54     1.5
@@ -420,7 +420,7 @@
     if (md5 == NULL || data_ptr == NULL)
         return MD5_RC_ARG;
     if (*data_ptr == NULL) {
-        if ((*data_ptr = malloc(MD5_LEN_STR+1)) == NULL)
+        if ((*data_ptr = (char *)malloc(MD5_LEN_STR+1)) == NULL)
             return MD5_RC_MEM;
         if (data_len != NULL)
             *data_len = MD5_LEN_STR+1;
@@ -435,10 +435,10 @@
 
     bufptr = buf;
     buflen = sizeof(buf);
-    if ((rc = md5_store(md5, (void *)(&bufptr), &buflen)) != MD5_RC_OK)
+    if ((rc = md5_store(md5, (void **)&bufptr, &buflen)) != MD5_RC_OK)
         return rc;
 
-    for (i = 0; i < buflen; i++) {
+    for (i = 0; i < (int)buflen; i++) {
             (*data_ptr)[(i*2)+0] = hex[(int)(bufptr[i] >> 4)];
             (*data_ptr)[(i*2)+1] = hex[(int)(bufptr[i] & 0x0f)];
     }


ossp-pkg/uuid/uuid_prng.c 1.1 -> 1.2

--- uuid_prng.c  2004/01/10 12:16:03     1.1
+++ uuid_prng.c  2004/01/18 19:22:54     1.2
@@ -94,7 +94,7 @@
 
     /* try to gather data from the system PRNG device */
     if (prng->devfd != -1) {
-        p = data_ptr;
+        p = (unsigned char *)data_ptr;
         n = data_len;
         cnt = 0;
         while (n > 0) {
@@ -112,7 +112,7 @@
 
     /* always also apply the weaker PRNG. In case the stronger PRNG device
        based source failed, this is the only remaining randomness, of course */
-    for (p = data_ptr, n = 0; n < data_len; n++)
+    for (p = (unsigned char *)data_ptr, n = 0; n < data_len; n++)
         *p++ ^= (unsigned char)(((unsigned int)rand() >> 7) & 0xFF);
 
     return PRNG_RC_OK;


ossp-pkg/uuid/uuid_str.c 1.1 -> 1.2

--- uuid_str.c   2004/01/13 19:43:15     1.1
+++ uuid_str.c   2004/01/18 19:22:54     1.2
@@ -557,7 +557,7 @@
 
     if (fracpart >= pow10(max)) {
         intpart++;
-        fracpart -= pow10(max);
+        fracpart -= (long)pow10(max);
     }
 
     /* convert integer part */
@@ -689,7 +689,7 @@
     char *rv;
     int n;
 
-    n = str_vsnprintf(NULL, -1, fmt, ap);
+    n = str_vsnprintf(NULL, 0, fmt, ap);
     if ((rv = (char *)malloc(n+1)) == NULL)
         return NULL;
     str_vsnprintf(rv, n+1, fmt, ap);
@@ -727,7 +727,7 @@
     }
     else {
         n = strlen(*str);
-        rv = str_vsnprintf(NULL, -1, fmt, ap);
+        rv = str_vsnprintf(NULL, 0, fmt, ap);
         if ((*str = (char *)realloc(*str, n+rv+1)) == NULL)
             return -1;
         str_vsnprintf((*str)+n, rv+1, fmt, ap);


ossp-pkg/uuid/uuid_ui64.c 1.1 -> 1.2

--- uuid_ui64.c  2004/01/09 11:32:06     1.1
+++ uuid_ui64.c  2004/01/18 19:22:55     1.2
@@ -149,7 +149,7 @@
                 str[i++] = map[r];
                 while (n > 1 && x.x[n-1] == 0)
                         n--;
-        } while (i < (len-1) && (n > 1 || x.x[0] != 0));
+        } while (i < ((int)len-1) && (n > 1 || x.x[0] != 0));
         str[i] = '\0';
     for (j = 0; j < --i; j++) {
         c = str[j];

CVSTrac 2.0.1