
It turns out that one of the reasons we had such trouble on HP-UX was that a C++ compiler was used, and it believes all .c files are C++. Lots of const's were required to shut the compiler up, along with explicit casts from (void *) and changes to variable names like "new". Adding "const" might help find some bugs (see below) but I won't pollute the mailing list with all the changes. If someone is interested, I can provide a context diff.
I have attached two files fixing possible bugs. The first file fixes a problem in lib/smi.c, where the comiler claims the implicit cast to unsigned long long happens too late to keep (1<<i) from being truncated to 32 bits. The second file fixes a possible character string overflow. (It doesn't happen with the current contents of the character string.)
*** /u/mcintosh/hp/src/libsmi-0.4.3.ori/lib/smi.c Wed Aug 18 05:51:01 2004 --- ./smi.c Tue May 3 08:41:54 2005 *************** *** 1595,1605 **** smiAsprintf(&s, f, smiValuePtr->value.unsigned64); } else if (smiTypePtr->format[0] == 'b') { for (i = 64 - 1; ! i > 0 && !(smiValuePtr->value.unsigned64 & (1 << i)); i--); ! s = smiMalloc(i + 1 + 1); if (s) { for (j = 0; i >= 0; i--, j++) { ! s[j] = smiValuePtr->value.unsigned64 & (1<<i) ? '1' : '0'; } s[j] = 0; } --- 1595,1605 ---- smiAsprintf(&s, f, smiValuePtr->value.unsigned64); } else if (smiTypePtr->format[0] == 'b') { for (i = 64 - 1; ! i > 0 && !(smiValuePtr->value.unsigned64 & ((unsigned long long)1 << i)); i--); ! s = (char *)smiMalloc(i + 1 + 1); if (s) { for (j = 0; i >= 0; i--, j++) { ! s[j] = smiValuePtr->value.unsigned64 & ((unsigned long long)1<<i) ? '1' : '0'; } s[j] = 0; }
*** /u/mcintosh/hp/src/libsmi-0.4.3.ori/tools/dump-xsd.c Wed Aug 18 05:50:59 2004 --- ./dump-xsd.c Mon May 2 23:02:26 2005 *************** *** 35,49 **** #define MIN(a,b) ((a)) < ((b)) ? ((a)) : ((b)) #endif /* #ifndef MIN */
! static char *schemaLocation = "http://www.ibr.cs.tu-bs.de/projects/libsmi/xsd/"; static int container = 0; static char *containerBasename = "container"; static int *nestAugmentedTables = 0; static int *nestSubtables = 0;
typedef struct XmlEscape { char character; char *escape; } XmlEscape;
static XmlEscape xmlEscapes [] = { --- 35,49 ---- #define MIN(a,b) ((a)) < ((b)) ? ((a)) : ((b)) #endif /* #ifndef MIN */
! static const char *schemaLocation = "http://www.ibr.cs.tu-bs.de/projects/libsmi/xsd/"; static int container = 0; static char *containerBasename = "container"; static int *nestAugmentedTables = 0; static int *nestSubtables = 0;
typedef struct XmlEscape { char character; char *escape; } XmlEscape;
static XmlEscape xmlEscapes [] = { *************** *** 2532,2538 ****
/* make sure url ends with '/' */ if( schemaLocation[ strlen( schemaLocation ) - 1 ] != '/' ) { ! smiAsprintf( &schemaLocation, "%s%c", schemaLocation, '/'); } if (container) { --- 2532,2540 ----
/* make sure url ends with '/' */ if( schemaLocation[ strlen( schemaLocation ) - 1 ] != '/' ) { ! char *s = (char *)malloc(strlen(schemaLocation)+2); ! smiAsprintf( &s, "%s%c", schemaLocation, '/'); ! schemaLocation = s; } if (container) {