I'm looking for how to fix the warnings that occur on 64-bit machines
associated with comparing property values with error values.

libmapi/mapidump.c:59: warning: cast from pointer to integer of different size
libmapi/freebusy.c:291: warning: cast from pointer to integer of different size
libmapi/freebusy.c:292: warning: cast from pointer to integer of different size
utils/openchangeclient.c:2683: warning: cast from pointer to integer of 
different size
utils/openchangeclient.c:2684: warning: cast from pointer to integer of 
different size
utils/openchangeclient.c:2693: warning: cast from pointer to integer of 
different size
utils/openchangeclient.c:2694: warning: cast from pointer to integer of 
different size
utils/openchangeclient.c:2703: warning: cast from pointer to integer of 
different size
utils/openchangeclient.c:2704: warning: cast from pointer to integer of 
different size

There would appear to be two options - never return an error value
(always make it NULL so we can just check for that), or add functions
that return the right type (or NULL) rather than a single function that
returns a void*. Here is a conceptual view:

[br...@colo1 openchangetrunk]$ svn diff libmapi
Index: libmapi/property.c
===================================================================
--- libmapi/property.c  (revision 1148)
+++ libmapi/property.c  (working copy)
@@ -223,6 +223,44 @@
        return NULL;
 }

+_PUBLIC_ const struct LongArray_r *find_SPropValue_data_MV_LONG(struct SRow 
*aRow, uint32_t mapitag)
+{
+       uint32_t i;
+
+       for (i = 0; i < aRow->cValues; i++) {
+               if (aRow->lpProps[i].ulPropTag == mapitag) {
+                       struct SPropValue *lpProps = &(aRow->lpProps[i]);
+                      if (lpProps->ulPropTag == 0) {
+                              return NULL;
+                      }
+
+                      if ( (lpProps->ulPropTag & 0xFFFF) == PT_MV_LONG) {
+                              return &(lpProps->value.MVl);
+                      }
+              }
+       }
+       return NULL;
+}
+
+_PUBLIC_ const struct BinaryArray_r *find_SPropValue_data_MV_BINARY(struct 
SRow *aRow, uint32_t mapitag)
+{
+       uint32_t i;
+
+       for (i = 0; i < aRow->cValues; i++) {
+               if (aRow->lpProps[i].ulPropTag == mapitag) {
+                       struct SPropValue *lpProps = &(aRow->lpProps[i]);
+                      if (lpProps->ulPropTag == 0) {
+                              return NULL;
+                      }
+
+                      if ( (lpProps->ulPropTag & 0xFFFF) == PT_MV_BINARY) {
+                              return &(lpProps->value.MVbin);
+                      }
+              }
+       }
+       return NULL;
+}
+
 _PUBLIC_ const void *find_mapi_SPropValue_data(
                                        struct mapi_SPropValue_array 
*properties, uint32_t mapitag)
 {
@@ -311,6 +349,32 @@
        }
 }

+_PUBLIC_ const void *get_SPropValue_data_STRING8(struct SPropValue *lpProps)
+{
+       if (lpProps->ulPropTag == 0) {
+               return NULL;
+       }
+
+       if ( (lpProps->ulPropTag & 0xFFFF) == PT_STRING8 ) {
+               return (const void *)lpProps->value.lpszA;
+       }
+
+       return NULL;
+}
+
+_PUBLIC_ const void *get_SPropValue_data_UNICODE(struct SPropValue *lpProps)
+{
+       if (lpProps->ulPropTag == 0) {
+               return NULL;
+       }
+
+       if ( (lpProps->ulPropTag & 0xFFFF) == PT_UNICODE ) {
+               return (const void *)lpProps->value.lpszW;
+       }
+
+       return NULL;
+}
+
 _PUBLIC_ bool set_SPropValue_proptag(struct SPropValue *lpProps, uint32_t 
aulPropTag, const void *data)
 {
        lpProps->ulPropTag = aulPropTag;
Index: libmapi/mapidump.c
===================================================================
--- libmapi/mapidump.c  (revision 1148)
+++ libmapi/mapidump.c  (working copy)
@@ -54,9 +54,12 @@
                printf("%s%s: %"PRIx64"\n", sep?sep:"", proptag, (*(const 
uint64_t *)data));
                break;
        case PT_STRING8:
+               data = get_SPropValue_data_STRING8(&lpProp);
+               printf("%s%s: %s\n", sep?sep:"", proptag, (data) ? (const char 
*)data : "NULL");
+               break;
        case PT_UNICODE:
-               data = get_SPropValue_data(&lpProp);
-               printf("%s%s: %s\n", sep?sep:"", proptag, (data && 
(uint32_t)data != MAPI_E_NOT_FOUND) ? (const char *)data : "NULL");
+               data = get_SPropValue_data_UNICODE(&lpProp);
+               printf("%s%s: %s\n", sep?sep:"", proptag, (data) ? (const char 
*)data : "NULL");
                break;
        case PT_SYSTIME:
                mapidump_date_SPropValue(lpProp, proptag);
Index: libmapi/freebusy.c
===================================================================
--- libmapi/freebusy.c  (revision 1148)
+++ libmapi/freebusy.c  (working copy)
@@ -285,11 +285,10 @@
        OPENCHANGE_RETVAL_IF(retval, retval, NULL);

        publish_start = (const uint32_t *) find_SPropValue_data(&aRow, 
PR_FREEBUSY_START_RANGE);
-       all_months = (const struct LongArray_r *) find_SPropValue_data(&aRow, 
PR_FREEBUSY_ALL_MONTHS);
-       all_events = (const struct BinaryArray_r *) find_SPropValue_data(&aRow, 
PR_FREEBUSY_ALL_EVENTS);
+       all_months = find_SPropValue_data_MV_LONG(&aRow, 
PR_FREEBUSY_ALL_MONTHS);
+       all_events = find_SPropValue_data_MV_BINARY(&aRow, 
PR_FREEBUSY_ALL_EVENTS);

-       if (!all_months || (uint32_t)all_months == MAPI_E_NOT_FOUND ||
-           !all_events || (uint32_t)all_events == MAPI_E_NOT_FOUND) {
+       if (!all_months || !all_events) {
                return MAPI_E_SUCCESS;
        }



Thoughts on this? 

Brad
_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel

Reply via email to