Index: dump-python.c =================================================================== --- dump-python.c (revision 7637) +++ dump-python.c (working copy) @@ -21,6 +21,7 @@ #include +#include #include #include #include @@ -325,23 +326,71 @@ SmiRange *lastrange = NULL; SmiValue min, max; - min.basetype = SMI_BASETYPE_UNSIGNED32; - min.value.unsigned32 = 4294967295U; + min.basetype = smiType->basetype; + max.basetype = smiType->basetype; - max.basetype = SMI_BASETYPE_UNSIGNED32; - max.value.unsigned32 = 0; + switch (smiType->basetype) { + case SMI_BASETYPE_INTEGER32: + min.value.integer32 = INT32_MAX; + max.value.integer32 = INT32_MIN; + break; + case SMI_BASETYPE_INTEGER64: + min.value.integer64 = INT64_MAX; + max.value.integer64 = INT64_MIN; + break; + case SMI_BASETYPE_UNSIGNED32: + min.value.unsigned32 = UINT32_MAX; + max.value.unsigned32 = 0; + break; + case SMI_BASETYPE_UNSIGNED64: + min.value.unsigned64 = LIBSMI_UINT64_MAX; + max.value.unsigned64 = 0; + break; + default: + fprintf(stderr, "smidump: unhandled SMI basetype\n"); + } fprintSegment(f, indent, "\"ranges\" : [\n", 0); for (range = smiGetFirstRange(smiType); range; range = smiGetNextRange(range)) { lastrange = range; - if (range->minValue.value.unsigned32 < min.value.unsigned32) { - min.value.unsigned32 = range->minValue.value.unsigned32; + switch (smiType->basetype) { + case SMI_BASETYPE_INTEGER32: + if (range->minValue.value.integer32 < min.value.integer32) { + min.value.integer32 = range->minValue.value.integer32; + } + if (range->maxValue.value.integer32 > max.value.integer32) { + max.value.integer32 = range->maxValue.value.integer32; + } + break; + case SMI_BASETYPE_INTEGER64: + if (range->minValue.value.integer64 < min.value.integer64) { + min.value.integer64 = range->minValue.value.integer64; + } + if (range->maxValue.value.integer64 > max.value.integer64) { + max.value.integer64 = range->maxValue.value.integer64; + } + break; + case SMI_BASETYPE_UNSIGNED32: + if (range->minValue.value.unsigned32 < min.value.unsigned32) { + min.value.unsigned32 = range->minValue.value.unsigned32; + } + if (range->maxValue.value.unsigned32 > max.value.unsigned32) { + max.value.unsigned32 = range->maxValue.value.unsigned32; + } + break; + case SMI_BASETYPE_UNSIGNED64: + if (range->minValue.value.unsigned64 < min.value.unsigned64) { + min.value.unsigned64 = range->minValue.value.unsigned64; + } + if (range->maxValue.value.unsigned64 > max.value.unsigned64) { + max.value.unsigned64 = range->maxValue.value.unsigned64; + } + break; + default: + break; } - if (range->maxValue.value.unsigned32 > max.value.unsigned32) { - max.value.unsigned32 = range->maxValue.value.unsigned32; - } fprintSegment(f, indent, "{\n", 0); fprintSegment(f, indent + INDENT, "", 0); fprint(f, "\"min\" : \"%s\",\n",