From efe4ef2029f261e8281e469fee7cca7120cc0c94 Mon Sep 17 00:00:00 2001 From: Bertho Stultiens Date: Fri, 13 Feb 2026 12:46:32 +0100 Subject: [PATCH 1/2] nml+cms: Replace non-functional 64-bit long int updaters with functional int64 types. --- src/libnml/cms/cms.cc | 8 +++--- src/libnml/cms/cms.hh | 10 ++++--- src/libnml/cms/cms_aup.cc | 58 +++++++++++++++++++-------------------- src/libnml/cms/cms_aup.hh | 8 +++--- src/libnml/cms/cms_dup.cc | 34 +++++++++++------------ src/libnml/cms/cms_dup.hh | 8 +++--- src/libnml/cms/cms_up.hh | 8 +++--- src/libnml/cms/cms_xup.cc | 36 ++++++++++++------------ src/libnml/cms/cms_xup.hh | 8 +++--- 9 files changed, 90 insertions(+), 88 deletions(-) diff --git a/src/libnml/cms/cms.cc b/src/libnml/cms/cms.cc index 5042411743a..824f45bffd4 100644 --- a/src/libnml/cms/cms.cc +++ b/src/libnml/cms/cms.cc @@ -1346,7 +1346,7 @@ CMS_STATUS CMS::update(unsigned int &x) } } -CMS_STATUS CMS::update(long int &x) +CMS_STATUS CMS::update(int64_t &x) { if (NULL != updater) { return (updater->update(x)); @@ -1355,7 +1355,7 @@ CMS_STATUS CMS::update(long int &x) } } -CMS_STATUS CMS::update(unsigned long int &x) +CMS_STATUS CMS::update(uint64_t &x) { if (NULL != updater) { return (updater->update(x)); @@ -1445,7 +1445,7 @@ CMS_STATUS CMS::update(unsigned int *x, unsigned int len) } } -CMS_STATUS CMS::update(long *x, unsigned int len) +CMS_STATUS CMS::update(int64_t *x, unsigned int len) { if (NULL != updater) { return (updater->update(x, len)); @@ -1454,7 +1454,7 @@ CMS_STATUS CMS::update(long *x, unsigned int len) } } -CMS_STATUS CMS::update(unsigned long *x, unsigned int len) +CMS_STATUS CMS::update(uint64_t *x, unsigned int len) { if (NULL != updater) { return (updater->update(x, len)); diff --git a/src/libnml/cms/cms.hh b/src/libnml/cms/cms.hh index f32262d0644..0f5c3df0cfa 100644 --- a/src/libnml/cms/cms.hh +++ b/src/libnml/cms/cms.hh @@ -16,6 +16,8 @@ #ifndef CMS_HH #define CMS_HH +#include + #ifdef __cplusplus extern "C" { #endif @@ -269,8 +271,8 @@ class CMS { CMS_STATUS update(unsigned short int &x); CMS_STATUS update(int &x); /* Used by emc2 */ CMS_STATUS update(unsigned int &x); - CMS_STATUS update(long int &x); /* Used by emc2 */ - CMS_STATUS update(unsigned long int &x); /* Used by emc2 */ + CMS_STATUS update(int64_t &x); /* Used by emc2 */ + CMS_STATUS update(uint64_t &x); /* Used by emc2 */ CMS_STATUS update(float &x); CMS_STATUS update(double &x); /* Used by emc2 */ CMS_STATUS update(long double &x); @@ -280,8 +282,8 @@ class CMS { CMS_STATUS update(unsigned short *x, unsigned int len); CMS_STATUS update(int *x, unsigned int len); /* Used by emc2 */ CMS_STATUS update(unsigned int *x, unsigned int len); - CMS_STATUS update(long *x, unsigned int len); - CMS_STATUS update(unsigned long *x, unsigned int len); + CMS_STATUS update(int64_t *x, unsigned int len); + CMS_STATUS update(uint64_t *x, unsigned int len); CMS_STATUS update(float *x, unsigned int len); CMS_STATUS update(double *x, unsigned int len); /* Used by emc2 */ CMS_STATUS update(long double *x, unsigned int len); diff --git a/src/libnml/cms/cms_aup.cc b/src/libnml/cms/cms_aup.cc index eaec4f50124..8b859055e3f 100644 --- a/src/libnml/cms/cms_aup.cc +++ b/src/libnml/cms/cms_aup.cc @@ -569,48 +569,48 @@ CMS_STATUS CMS_ASCII_UPDATER::update(unsigned int *x, unsigned int len) /* Long functions */ -CMS_STATUS CMS_ASCII_UPDATER::update(long int &x) +CMS_STATUS CMS_ASCII_UPDATER::update(int64_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(long))) { + if (-1 == check_pointer((char *) &x, sizeof(int64_t))) { return (status = CMS_UPDATE_ERROR); } if (encoding) { - end_current_string[15] = 0; - sprintf(end_current_string, "%-14ld", x); - if (end_current_string[15] != 0 && warning_count < warning_count_max) { + end_current_string[22] = 0; + sprintf(end_current_string, "%-21ld", x); + if (end_current_string[22] != 0 && warning_count < warning_count_max) { warning_count++; rcs_print_error - ("CMS_ASCII_UPDATER: (warning) long with value %-14ld caused an overflow\n", + ("CMS_ASCII_UPDATER: (warning) int64_t with value %-21ld caused an overflow\n", x); } - end_current_string[15] = 0; + end_current_string[22] = 0; } else { - if (-1 == safe_strlen(end_current_string, 16)) { + if (-1 == safe_strlen(end_current_string, 23)) { rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n"); return (status = CMS_UPDATE_ERROR); } errno = 0; - long number = strtol(end_current_string, (char **) NULL, 10); + int64_t number = strtoll(end_current_string, (char **) NULL, 10); if (errno != 0) { rcs_print_error - ("CMS_ASCII_UPDATER: Error %d occurred during strtol.\n", + ("CMS_ASCII_UPDATER: Error %d occurred during strtoll.\n", errno); return (status = CMS_UPDATE_ERROR); } x = number; } - end_current_string += 16; - length_current_string += 16; + end_current_string += 23; + length_current_string += 23; return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(long *x, unsigned int len) +CMS_STATUS CMS_ASCII_UPDATER::update(int64_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(long) * len)) { + if (-1 == check_pointer((char *) x, sizeof(int64_t) * len)) { return (status = CMS_UPDATE_ERROR); } @@ -622,49 +622,49 @@ CMS_STATUS CMS_ASCII_UPDATER::update(long *x, unsigned int len) return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(unsigned long int &x) +CMS_STATUS CMS_ASCII_UPDATER::update(uint64_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(unsigned long))) { + if (-1 == check_pointer((char *) &x, sizeof(uint64_t))) { return (status = CMS_UPDATE_ERROR); } if (encoding) { - end_current_string[15] = 0; - sprintf(end_current_string, "%-14lu", x); - if (end_current_string[15] != 0 && warning_count < warning_count_max) { + end_current_string[22] = 0; + sprintf(end_current_string, "%-21lu", x); + if (end_current_string[22] != 0 && warning_count < warning_count_max) { warning_count++; rcs_print_error - ("CMS_ASCII_UPDATER: (warning) unsigned long with value %-14ld caused an overflow\n", + ("CMS_ASCII_UPDATER: (warning) uint64_t with value %-21ld caused an overflow\n", x); } - end_current_string[15] = 0; + end_current_string[22] = 0; } else { - if (-1 == safe_strlen(end_current_string, 16)) { + if (-1 == safe_strlen(end_current_string, 23)) { rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n"); return (status = CMS_UPDATE_ERROR); } errno = 0; - unsigned long - number = strtoul(end_current_string, (char **) NULL, 10); + uint64_t + number = strtoull(end_current_string, (char **) NULL, 10); if (errno != 0) { rcs_print_error - ("CMS_ASCII_UPDATER: Error %d:%s occurred during strtoul of(%s).\n", + ("CMS_ASCII_UPDATER: Error %d:%s occurred during strtoull of(%s).\n", errno, strerror(errno), end_current_string); return (status = CMS_UPDATE_ERROR); } x = number; } - end_current_string += 16; - length_current_string += 16; + end_current_string += 23; + length_current_string += 23; return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(unsigned long *x, unsigned int len) +CMS_STATUS CMS_ASCII_UPDATER::update(uint64_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(unsigned long) * len)) { + if (-1 == check_pointer((char *) x, sizeof(uint64_t) * len)) { return (status = CMS_UPDATE_ERROR); } diff --git a/src/libnml/cms/cms_aup.hh b/src/libnml/cms/cms_aup.hh index c61cbe93a70..ad555811f11 100644 --- a/src/libnml/cms/cms_aup.hh +++ b/src/libnml/cms/cms_aup.hh @@ -25,8 +25,8 @@ class CMS_ASCII_UPDATER:public CMS_UPDATER { CMS_STATUS update(unsigned short int &x); CMS_STATUS update(int &x); CMS_STATUS update(unsigned int &x); - CMS_STATUS update(long int &x); - CMS_STATUS update(unsigned long int &x); + CMS_STATUS update(int64_t &x); + CMS_STATUS update(uint64_t &x); CMS_STATUS update(float &x); CMS_STATUS update(double &x); CMS_STATUS update(long double &x); @@ -36,8 +36,8 @@ class CMS_ASCII_UPDATER:public CMS_UPDATER { CMS_STATUS update(unsigned short *x, unsigned int len); CMS_STATUS update(int *x, unsigned int len); CMS_STATUS update(unsigned int *x, unsigned int len); - CMS_STATUS update(long *x, unsigned int len); - CMS_STATUS update(unsigned long *x, unsigned int len); + CMS_STATUS update(int64_t *x, unsigned int len); + CMS_STATUS update(uint64_t *x, unsigned int len); CMS_STATUS update(float *x, unsigned int len); CMS_STATUS update(double *x, unsigned int len); CMS_STATUS update(long double *x, unsigned int len); diff --git a/src/libnml/cms/cms_dup.cc b/src/libnml/cms/cms_dup.cc index 57df25519e2..f97d6228432 100644 --- a/src/libnml/cms/cms_dup.cc +++ b/src/libnml/cms/cms_dup.cc @@ -575,33 +575,33 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned int *x, /* Long functions */ -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(long int &x) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int64_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(long))) { + if (-1 == check_pointer((char *) &x, sizeof(int64_t))) { return (CMS_UPDATE_ERROR); } if (encoding) { - end_current_string[15] = 0; + end_current_string[22] = 0; snprintf(end_current_string, max_length_current_string-(end_current_string - begin_current_string), "%+ld,", x); - if (end_current_string[15] != 0 && warning_count < warning_count_max) { + if (end_current_string[22] != 0 && warning_count < warning_count_max) { warning_count++; rcs_print_error - ("CMS_DISPLAY_ASCII_UPDATER: (warning) long with value %-14ld caused an overflow\n", + ("CMS_DISPLAY_ASCII_UPDATER: (warning) int64_t with value %-21ld caused an overflow\n", x); } - end_current_string[15] = 0; + end_current_string[22] = 0; } else { if (0 == end_current_string[0]) { x = 0; return status; } errno = 0; - long number = strtol(end_current_string, (char **) NULL, 10); + int64_t number = strtoll(end_current_string, (char **) NULL, 10); if (errno != 0) { rcs_print_error - ("CMS_DISPLAY_ASCII_UPDATER: Error %d: %s occurred during strtol of(%s).\n", + ("CMS_DISPLAY_ASCII_UPDATER: Error %d: %s occurred during strtoll of(%s).\n", errno, strerror(errno), end_current_string); return (status = CMS_UPDATE_ERROR); } @@ -612,10 +612,10 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(long int &x) return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(long *x, unsigned int len) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int64_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(long) * len)) { + if (-1 == check_pointer((char *) x, sizeof(int64_t) * len)) { return (CMS_UPDATE_ERROR); } @@ -627,10 +627,10 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(long *x, unsigned int len) return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned long int &x) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(uint64_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(unsigned long))) { + if (-1 == check_pointer((char *) &x, sizeof(uint64_t))) { return (CMS_UPDATE_ERROR); } @@ -643,11 +643,11 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned long int &x) return status; } errno = 0; - unsigned long number = - strtoul(end_current_string, (char **) NULL, 10); + uint64_t number = + strtoull(end_current_string, (char **) NULL, 10); if (errno != 0) { rcs_print_error - ("CMS_DISPLAY_ASCII_UPDATER: Error %d:%s occurred during strtoul of(%s).\n", + ("CMS_DISPLAY_ASCII_UPDATER: Error %d:%s occurred during strtoull of(%s).\n", errno, strerror(errno), end_current_string); return (status = CMS_UPDATE_ERROR); } @@ -658,11 +658,11 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned long int &x) return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned long *x, +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(uint64_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(unsigned long) * len)) { + if (-1 == check_pointer((char *) x, sizeof(uint64_t) * len)) { return (CMS_UPDATE_ERROR); } diff --git a/src/libnml/cms/cms_dup.hh b/src/libnml/cms/cms_dup.hh index b54b9f0d526..483f791dc8d 100644 --- a/src/libnml/cms/cms_dup.hh +++ b/src/libnml/cms/cms_dup.hh @@ -28,8 +28,8 @@ class CMS_DISPLAY_ASCII_UPDATER:public CMS_UPDATER { CMS_STATUS update(unsigned short int &x); CMS_STATUS update(int &x); CMS_STATUS update(unsigned int &x); - CMS_STATUS update(long int &x); - CMS_STATUS update(unsigned long int &x); + CMS_STATUS update(int64_t &x); + CMS_STATUS update(uint64_t &x); CMS_STATUS update(float &x); CMS_STATUS update(double &x); CMS_STATUS update(long double &x); @@ -39,8 +39,8 @@ class CMS_DISPLAY_ASCII_UPDATER:public CMS_UPDATER { CMS_STATUS update(unsigned short *x, unsigned int len); CMS_STATUS update(int *x, unsigned int len); CMS_STATUS update(unsigned int *x, unsigned int len); - CMS_STATUS update(long *x, unsigned int len); - CMS_STATUS update(unsigned long *x, unsigned int len); + CMS_STATUS update(int64_t *x, unsigned int len); + CMS_STATUS update(uint64_t *x, unsigned int len); CMS_STATUS update(float *x, unsigned int len); CMS_STATUS update(double *x, unsigned int len); CMS_STATUS update(long double *x, unsigned int len); diff --git a/src/libnml/cms/cms_up.hh b/src/libnml/cms/cms_up.hh index 9eae5d1a33a..a0eae7df88e 100644 --- a/src/libnml/cms/cms_up.hh +++ b/src/libnml/cms/cms_up.hh @@ -45,8 +45,8 @@ class CMS_UPDATER { virtual CMS_STATUS update(unsigned short int &x) = 0; virtual CMS_STATUS update(int &x) = 0; virtual CMS_STATUS update(unsigned int &x) = 0; - virtual CMS_STATUS update(long int &x) = 0; - virtual CMS_STATUS update(unsigned long int &x) = 0; + virtual CMS_STATUS update(int64_t &x) = 0; + virtual CMS_STATUS update(uint64_t &x) = 0; virtual CMS_STATUS update(float &x) = 0; virtual CMS_STATUS update(double &x) = 0; virtual CMS_STATUS update(long double &x) = 0; @@ -56,8 +56,8 @@ class CMS_UPDATER { virtual CMS_STATUS update(unsigned short *x, unsigned int len) = 0; virtual CMS_STATUS update(int *x, unsigned int len) = 0; virtual CMS_STATUS update(unsigned int *x, unsigned int len) = 0; - virtual CMS_STATUS update(long *x, unsigned int len) = 0; - virtual CMS_STATUS update(unsigned long *x, unsigned int len) = 0; + virtual CMS_STATUS update(int64_t *x, unsigned int len) = 0; + virtual CMS_STATUS update(uint64_t *x, unsigned int len) = 0; virtual CMS_STATUS update(float *x, unsigned int len) = 0; virtual CMS_STATUS update(double *x, unsigned int len) = 0; virtual CMS_STATUS update(long double *x, unsigned int len) = 0; diff --git a/src/libnml/cms/cms_xup.cc b/src/libnml/cms/cms_xup.cc index e5dd417a458..7223fb4e622 100644 --- a/src/libnml/cms/cms_xup.cc +++ b/src/libnml/cms/cms_xup.cc @@ -512,59 +512,59 @@ CMS_STATUS CMS_XDR_UPDATER::update(unsigned int *x, unsigned int len) /* LONG */ -CMS_STATUS CMS_XDR_UPDATER::update(long int &x) +CMS_STATUS CMS_XDR_UPDATER::update(int64_t &x) { - if (-1 == check_pointer((char *) &x, sizeof(long))) { + if (-1 == check_pointer((char *) &x, sizeof(int64_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_long(current_stream, &x) != TRUE) { - rcs_print_error("CMS_XDR_UPDATER: xdr_long failed.\n"); + if (xdr_int64_t(current_stream, &x) != TRUE) { + rcs_print_error("CMS_XDR_UPDATER: xdr_int64_t failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(long *x, unsigned int len) +CMS_STATUS CMS_XDR_UPDATER::update(int64_t *x, unsigned int len) { - if (-1 == check_pointer((char *) x, len * sizeof(long))) { + if (-1 == check_pointer((char *) x, len * sizeof(int64_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_vector(current_stream, (char *) x, len, sizeof(long), - (xdrproc_t) xdr_long) != TRUE) { + if (xdr_vector(current_stream, (char *) x, len, sizeof(int64_t), + (xdrproc_t) xdr_int64_t) != TRUE) { rcs_print_error - ("CMS_XDR_UPDATER: xdr_vector(... xdr_long) failed.\n"); + ("CMS_XDR_UPDATER: xdr_vector(... xdr_int64_t) failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(unsigned long int &x) +CMS_STATUS CMS_XDR_UPDATER::update(uint64_t &x) { - if (-1 == check_pointer((char *) &x, sizeof(unsigned long))) { + if (-1 == check_pointer((char *) &x, sizeof(uint64_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_u_long(current_stream, &x) != TRUE) { - rcs_print_error("CMS_XDR_UPDATER: xdr_u_long failed.\n"); + if (xdr_uint64_t(current_stream, &x) != TRUE) { + rcs_print_error("CMS_XDR_UPDATER: xdr_uint64_t failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(unsigned long *x, unsigned int len) +CMS_STATUS CMS_XDR_UPDATER::update(uint64_t *x, unsigned int len) { - if (-1 == check_pointer((char *) x, len * sizeof(unsigned long))) { + if (-1 == check_pointer((char *) x, len * sizeof(uint64_t))) { return (CMS_UPDATE_ERROR); } if (xdr_vector(current_stream, - (char *) x, len, sizeof(unsigned long), - (xdrproc_t) xdr_u_long) != TRUE) { + (char *) x, len, sizeof(uint64_t), + (xdrproc_t) xdr_uint64_t) != TRUE) { rcs_print_error - ("CMS_XDR_UPDATER: xdr_vector(... xdr_u_long) failed.\n"); + ("CMS_XDR_UPDATER: xdr_vector(... xdr_uint64_t) failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); diff --git a/src/libnml/cms/cms_xup.hh b/src/libnml/cms/cms_xup.hh index c840c284387..6644bd00e48 100644 --- a/src/libnml/cms/cms_xup.hh +++ b/src/libnml/cms/cms_xup.hh @@ -29,8 +29,8 @@ class CMS_XDR_UPDATER:public CMS_UPDATER { CMS_STATUS update(unsigned short int &x); CMS_STATUS update(int &x); CMS_STATUS update(unsigned int &x); - CMS_STATUS update(long int &x); - CMS_STATUS update(unsigned long int &x); + CMS_STATUS update(int64_t &x); + CMS_STATUS update(uint64_t &x); CMS_STATUS update(float &x); CMS_STATUS update(double &x); CMS_STATUS update(long double &x); @@ -40,8 +40,8 @@ class CMS_XDR_UPDATER:public CMS_UPDATER { CMS_STATUS update(unsigned short *x, unsigned int len); CMS_STATUS update(int *x, unsigned int len); CMS_STATUS update(unsigned int *x, unsigned int len); - CMS_STATUS update(long *x, unsigned int len); - CMS_STATUS update(unsigned long *x, unsigned int len); + CMS_STATUS update(int64_t *x, unsigned int len); + CMS_STATUS update(uint64_t *x, unsigned int len); CMS_STATUS update(float *x, unsigned int len); CMS_STATUS update(double *x, unsigned int len); CMS_STATUS update(long double *x, unsigned int len); From b87d3ce6aaba745e763d21d606ab9704bf4761bb Mon Sep 17 00:00:00 2001 From: Bertho Stultiens Date: Fri, 13 Feb 2026 23:48:39 +0100 Subject: [PATCH 2/2] nml+cms: Update all update functions to use [u]int{8,16,32,64}_t types. --- src/libnml/cms/cms.cc | 24 +++++----- src/libnml/cms/cms.hh | 33 ++++++------- src/libnml/cms/cms_aup.cc | 86 ++++++++++++++++++---------------- src/libnml/cms/cms_aup.hh | 24 +++++----- src/libnml/cms/cms_dup.cc | 97 +++++++++++++++++++++------------------ src/libnml/cms/cms_dup.hh | 24 +++++----- src/libnml/cms/cms_up.hh | 24 +++++----- src/libnml/cms/cms_xup.cc | 92 ++++++++++++++++++------------------- src/libnml/cms/cms_xup.hh | 25 +++++----- 9 files changed, 224 insertions(+), 205 deletions(-) diff --git a/src/libnml/cms/cms.cc b/src/libnml/cms/cms.cc index 824f45bffd4..85454faf2e0 100644 --- a/src/libnml/cms/cms.cc +++ b/src/libnml/cms/cms.cc @@ -1292,7 +1292,7 @@ CMS_STATUS CMS::update(bool &x) } } -CMS_STATUS CMS::update(char &x) +CMS_STATUS CMS::update(int8_t &x) { if (NULL != updater) { return (updater->update(x)); @@ -1301,7 +1301,7 @@ CMS_STATUS CMS::update(char &x) } } -CMS_STATUS CMS::update(unsigned char &x) +CMS_STATUS CMS::update(uint8_t &x) { if (NULL != updater) { return (updater->update(x)); @@ -1310,7 +1310,7 @@ CMS_STATUS CMS::update(unsigned char &x) } } -CMS_STATUS CMS::update(short int &x) +CMS_STATUS CMS::update(int16_t &x) { if (NULL != updater) { return (updater->update(x)); @@ -1319,7 +1319,7 @@ CMS_STATUS CMS::update(short int &x) } } -CMS_STATUS CMS::update(unsigned short int &x) +CMS_STATUS CMS::update(uint16_t &x) { if (NULL != updater) { return (updater->update(x)); @@ -1328,7 +1328,7 @@ CMS_STATUS CMS::update(unsigned short int &x) } } -CMS_STATUS CMS::update(int &x) +CMS_STATUS CMS::update(int32_t &x) { if (NULL != updater) { return (updater->update(x)); @@ -1337,7 +1337,7 @@ CMS_STATUS CMS::update(int &x) } } -CMS_STATUS CMS::update(unsigned int &x) +CMS_STATUS CMS::update(uint32_t &x) { if (NULL != updater) { return (updater->update(x)); @@ -1391,7 +1391,7 @@ CMS_STATUS CMS::update(long double &x) } } -CMS_STATUS CMS::update(char *x, unsigned int len) +CMS_STATUS CMS::update(int8_t *x, unsigned int len) { if (NULL != updater) { return (updater->update(x, len)); @@ -1400,7 +1400,7 @@ CMS_STATUS CMS::update(char *x, unsigned int len) } } -CMS_STATUS CMS::update(unsigned char *x, unsigned int len) +CMS_STATUS CMS::update(uint8_t *x, unsigned int len) { if (NULL != updater) { return (updater->update(x, len)); @@ -1409,7 +1409,7 @@ CMS_STATUS CMS::update(unsigned char *x, unsigned int len) } } -CMS_STATUS CMS::update(short *x, unsigned int len) +CMS_STATUS CMS::update(int16_t *x, unsigned int len) { if (NULL != updater) { return (updater->update(x, len)); @@ -1418,7 +1418,7 @@ CMS_STATUS CMS::update(short *x, unsigned int len) } } -CMS_STATUS CMS::update(unsigned short *x, unsigned int len) +CMS_STATUS CMS::update(uint16_t *x, unsigned int len) { if (NULL != updater) { return (updater->update(x, len)); @@ -1427,7 +1427,7 @@ CMS_STATUS CMS::update(unsigned short *x, unsigned int len) } } -CMS_STATUS CMS::update(int *x, unsigned int len) +CMS_STATUS CMS::update(int32_t *x, unsigned int len) { if (NULL != updater) { return (updater->update(x, len)); @@ -1436,7 +1436,7 @@ CMS_STATUS CMS::update(int *x, unsigned int len) } } -CMS_STATUS CMS::update(unsigned int *x, unsigned int len) +CMS_STATUS CMS::update(uint32_t *x, unsigned int len) { if (NULL != updater) { return (updater->update(x, len)); diff --git a/src/libnml/cms/cms.hh b/src/libnml/cms/cms.hh index 0f5c3df0cfa..ef4c5a68507 100644 --- a/src/libnml/cms/cms.hh +++ b/src/libnml/cms/cms.hh @@ -265,27 +265,28 @@ class CMS { /***********************************************/ /* Access functions for primitive C language data types */ CMS_STATUS update(bool &x); - CMS_STATUS update(char &x); /* Used by emc2 */ - CMS_STATUS update(unsigned char &x); /* Used by emc2 */ - CMS_STATUS update(short int &x); - CMS_STATUS update(unsigned short int &x); - CMS_STATUS update(int &x); /* Used by emc2 */ - CMS_STATUS update(unsigned int &x); - CMS_STATUS update(int64_t &x); /* Used by emc2 */ - CMS_STATUS update(uint64_t &x); /* Used by emc2 */ + CMS_STATUS update(int8_t &x); + CMS_STATUS update(uint8_t &x); + CMS_STATUS update(int16_t &x); + CMS_STATUS update(uint16_t &x); + CMS_STATUS update(int32_t &x); + CMS_STATUS update(uint32_t &x); + CMS_STATUS update(int64_t &x); + CMS_STATUS update(uint64_t &x); CMS_STATUS update(float &x); - CMS_STATUS update(double &x); /* Used by emc2 */ + CMS_STATUS update(double &x); CMS_STATUS update(long double &x); - CMS_STATUS update(char *x, unsigned int len); /* Used by emc2 */ - CMS_STATUS update(unsigned char *x, unsigned int len); /* Used by emc2 */ - CMS_STATUS update(short *x, unsigned int len); - CMS_STATUS update(unsigned short *x, unsigned int len); - CMS_STATUS update(int *x, unsigned int len); /* Used by emc2 */ - CMS_STATUS update(unsigned int *x, unsigned int len); + CMS_STATUS update(char *x, unsigned int len) { return update(reinterpret_cast(x), len); }; + CMS_STATUS update(int8_t *x, unsigned int len); + CMS_STATUS update(uint8_t *x, unsigned int len); + CMS_STATUS update(int16_t *x, unsigned int len); + CMS_STATUS update(uint16_t *x, unsigned int len); + CMS_STATUS update(int32_t *x, unsigned int len); + CMS_STATUS update(uint32_t *x, unsigned int len); CMS_STATUS update(int64_t *x, unsigned int len); CMS_STATUS update(uint64_t *x, unsigned int len); CMS_STATUS update(float *x, unsigned int len); - CMS_STATUS update(double *x, unsigned int len); /* Used by emc2 */ + CMS_STATUS update(double *x, unsigned int len); CMS_STATUS update(long double *x, unsigned int len); /************************************************************************* diff --git a/src/libnml/cms/cms_aup.cc b/src/libnml/cms/cms_aup.cc index 8b859055e3f..8d68d6a496c 100644 --- a/src/libnml/cms/cms_aup.cc +++ b/src/libnml/cms/cms_aup.cc @@ -44,6 +44,12 @@ extern "C" { CMS_ASCII_UPDATER::CMS_ASCII_UPDATER(CMS * _cms_parent):CMS_UPDATER (_cms_parent) { + fprintf(stderr, + "* * * * * * * * - - - - - WARNING - - - - - * * * * * * * *\n" + "* CMS_ASCII_UPDATER may not function properly due to *\n" + "* range limitations of some of the update() functions. *\n" + "* * * * * * * * - - - - - WARNING - - - - - * * * * * * * *\n"); + /* Set pointers to NULL. */ begin_current_string = (char *) NULL; end_current_string = (char *) NULL; @@ -241,17 +247,17 @@ CMS_STATUS CMS_ASCII_UPDATER::update(bool &x) /* Char functions */ -CMS_STATUS CMS_ASCII_UPDATER::update(char &x) +CMS_STATUS CMS_ASCII_UPDATER::update(int8_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(char))) { + if (-1 == check_pointer((char *) &x, sizeof(int8_t))) { return (CMS_UPDATE_ERROR); } if (encoding) { - end_current_string[0] = x; + end_current_string[0] = (char)x; } else { - x = end_current_string[0]; + x = (int8_t)end_current_string[0]; } end_current_string += 1; length_current_string += 1; @@ -259,10 +265,10 @@ CMS_STATUS CMS_ASCII_UPDATER::update(char &x) return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(char *x, unsigned int len) +CMS_STATUS CMS_ASCII_UPDATER::update(int8_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(char) * len)) { + if (-1 == check_pointer((char *) x, sizeof(int8_t) * len)) { return (status = CMS_UPDATE_ERROR); } @@ -278,17 +284,17 @@ CMS_STATUS CMS_ASCII_UPDATER::update(char *x, unsigned int len) /* Char functions */ -CMS_STATUS CMS_ASCII_UPDATER::update(unsigned char &x) +CMS_STATUS CMS_ASCII_UPDATER::update(uint8_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(unsigned char))) { + if (-1 == check_pointer((char *) &x, sizeof(uint8_t))) { return (status = CMS_UPDATE_ERROR); } if (encoding) { - end_current_string[0] = x; + end_current_string[0] = (char)x; } else { - x = end_current_string[0]; + x = (uint8_t)end_current_string[0]; } end_current_string += 1; length_current_string += 1; @@ -296,10 +302,10 @@ CMS_STATUS CMS_ASCII_UPDATER::update(unsigned char &x) return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(unsigned char *x, unsigned int len) +CMS_STATUS CMS_ASCII_UPDATER::update(uint8_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(unsigned char) * len)) { + if (-1 == check_pointer((char *) x, sizeof(uint8_t) * len)) { return (status = CMS_UPDATE_ERROR); } @@ -315,10 +321,10 @@ CMS_STATUS CMS_ASCII_UPDATER::update(unsigned char *x, unsigned int len) /* Short functions */ -CMS_STATUS CMS_ASCII_UPDATER::update(short int &x) +CMS_STATUS CMS_ASCII_UPDATER::update(int16_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(short))) { + if (-1 == check_pointer((char *) &x, sizeof(int16_t))) { return (status = CMS_UPDATE_ERROR); } @@ -345,12 +351,12 @@ CMS_STATUS CMS_ASCII_UPDATER::update(short int &x) errno, strerror(errno), end_current_string); return (status = CMS_UPDATE_ERROR); } - if ((number < SHRT_MIN || SHRT_MAX < number) + if ((number < INT16_MIN || INT16_MAX < number) && warning_count < warning_count_max) { warning_count++; rcs_print_error - ("CMS_ASCII_UPDATER: (warning) Number %ld out of range for short(%d,%d)\n", - number, SHRT_MIN, SHRT_MAX); + ("CMS_ASCII_UPDATER: (warning) Number %ld out of range for int16_t(%d,%d)\n", + number, INT_MIN, INT_MAX); } x = (short) number; } @@ -360,10 +366,10 @@ CMS_STATUS CMS_ASCII_UPDATER::update(short int &x) return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(short *x, unsigned int len) +CMS_STATUS CMS_ASCII_UPDATER::update(int16_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(short) * len)) { + if (-1 == check_pointer((char *) x, sizeof(int16_t) * len)) { return (status = CMS_UPDATE_ERROR); } @@ -375,10 +381,10 @@ CMS_STATUS CMS_ASCII_UPDATER::update(short *x, unsigned int len) return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(unsigned short int &x) +CMS_STATUS CMS_ASCII_UPDATER::update(uint16_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(short))) { + if (-1 == check_pointer((char *) &x, sizeof(uint16_t))) { return (status = CMS_UPDATE_ERROR); } @@ -406,11 +412,11 @@ CMS_STATUS CMS_ASCII_UPDATER::update(unsigned short int &x) errno, strerror(errno), end_current_string); return (status = CMS_UPDATE_ERROR); } - if (number > USHRT_MAX && warning_count < warning_count_max) { + if (number > UINT16_MAX && warning_count < warning_count_max) { warning_count++; rcs_print_error - ("CMS_ASCII_UPDATER: Number %lu out of range for unsigned short(0,%d)\n", - number, USHRT_MAX); + ("CMS_ASCII_UPDATER: Number %lu out of range for uint16_t(0,%d)\n", + number, UINT16_MAX); } x = (unsigned short) number; } @@ -420,10 +426,10 @@ CMS_STATUS CMS_ASCII_UPDATER::update(unsigned short int &x) return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(unsigned short *x, unsigned int len) +CMS_STATUS CMS_ASCII_UPDATER::update(uint16_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(unsigned short) * len)) { + if (-1 == check_pointer((char *) x, sizeof(uint16_t) * len)) { return (status = CMS_UPDATE_ERROR); } @@ -437,14 +443,15 @@ CMS_STATUS CMS_ASCII_UPDATER::update(unsigned short *x, unsigned int len) /* Int functions */ -CMS_STATUS CMS_ASCII_UPDATER::update(int &x) +CMS_STATUS CMS_ASCII_UPDATER::update(int32_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(int))) { + if (-1 == check_pointer((char *) &x, sizeof(int32_t))) { return (status = CMS_UPDATE_ERROR); } if (encoding) { + // FIXME: Bad range if (x > 9999999 && warning_count < warning_count_max) { warning_count++; rcs_print_error @@ -473,11 +480,11 @@ CMS_STATUS CMS_ASCII_UPDATER::update(int &x) errno, strerror(errno), end_current_string); return (status = CMS_UPDATE_ERROR); } - if ((number < ((long) INT_MIN)) || ((((long) INT_MAX) < number) && (warning_count < warning_count_max))) { + if ((number < ((long) INT32_MIN)) || ((((long) INT32_MAX) < number) && (warning_count < warning_count_max))) { warning_count++; rcs_print_error ("CMS_ASCII_UPDATER: (warning) Number %ld out of range for int(%d,%d)\n", - number, INT_MIN, INT_MAX); + number, INT32_MIN, INT32_MAX); } x = (int) number; } @@ -487,10 +494,10 @@ CMS_STATUS CMS_ASCII_UPDATER::update(int &x) return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(int *x, unsigned int len) +CMS_STATUS CMS_ASCII_UPDATER::update(int32_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(int) * len)) { + if (-1 == check_pointer((char *) x, sizeof(int32_t) * len)) { return (status = CMS_UPDATE_ERROR); } @@ -502,14 +509,15 @@ CMS_STATUS CMS_ASCII_UPDATER::update(int *x, unsigned int len) return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(unsigned int &x) +CMS_STATUS CMS_ASCII_UPDATER::update(uint32_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(unsigned int))) { + if (-1 == check_pointer((char *) &x, sizeof(uint32_t))) { return (status = CMS_UPDATE_ERROR); } if (encoding) { + // FIXME: Bad range if (x > 9999999 && warning_count < warning_count_max) { warning_count++; rcs_print_error @@ -539,10 +547,10 @@ CMS_STATUS CMS_ASCII_UPDATER::update(unsigned int &x) errno, strerror(errno), end_current_string); return (status = CMS_UPDATE_ERROR); } - if (UINT_MAX < number && warning_count < warning_count_max) { + if (UINT32_MAX < number && warning_count < warning_count_max) { rcs_print_error - ("CMS_ASCII_UPDATER: Number %lu out of range for unsigned int (0,%u)\n", - number, UINT_MAX); + ("CMS_ASCII_UPDATER: Number %lu out of range for uint32_t (0,%u)\n", + number, UINT32_MAX); } x = (unsigned int) number; } @@ -552,10 +560,10 @@ CMS_STATUS CMS_ASCII_UPDATER::update(unsigned int &x) return (status); } -CMS_STATUS CMS_ASCII_UPDATER::update(unsigned int *x, unsigned int len) +CMS_STATUS CMS_ASCII_UPDATER::update(uint32_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(unsigned int) * len)) { + if (-1 == check_pointer((char *) x, sizeof(uint32_t) * len)) { return (status = CMS_UPDATE_ERROR); } diff --git a/src/libnml/cms/cms_aup.hh b/src/libnml/cms/cms_aup.hh index ad555811f11..61777b69a68 100644 --- a/src/libnml/cms/cms_aup.hh +++ b/src/libnml/cms/cms_aup.hh @@ -19,23 +19,23 @@ class CMS_ASCII_UPDATER:public CMS_UPDATER { public: CMS_STATUS update(bool &x); - CMS_STATUS update(char &x); - CMS_STATUS update(unsigned char &x); - CMS_STATUS update(short int &x); - CMS_STATUS update(unsigned short int &x); - CMS_STATUS update(int &x); - CMS_STATUS update(unsigned int &x); + CMS_STATUS update(int8_t &x); + CMS_STATUS update(uint8_t &x); + CMS_STATUS update(int16_t &x); + CMS_STATUS update(uint16_t &x); + CMS_STATUS update(int32_t &x); + CMS_STATUS update(uint32_t &x); CMS_STATUS update(int64_t &x); CMS_STATUS update(uint64_t &x); CMS_STATUS update(float &x); CMS_STATUS update(double &x); CMS_STATUS update(long double &x); - CMS_STATUS update(char *x, unsigned int len); - CMS_STATUS update(unsigned char *x, unsigned int len); - CMS_STATUS update(short *x, unsigned int len); - CMS_STATUS update(unsigned short *x, unsigned int len); - CMS_STATUS update(int *x, unsigned int len); - CMS_STATUS update(unsigned int *x, unsigned int len); + CMS_STATUS update(int8_t *x, unsigned int len); + CMS_STATUS update(uint8_t *x, unsigned int len); + CMS_STATUS update(int16_t *x, unsigned int len); + CMS_STATUS update(uint16_t *x, unsigned int len); + CMS_STATUS update(int32_t *x, unsigned int len); + CMS_STATUS update(uint32_t *x, unsigned int len); CMS_STATUS update(int64_t *x, unsigned int len); CMS_STATUS update(uint64_t *x, unsigned int len); CMS_STATUS update(float *x, unsigned int len); diff --git a/src/libnml/cms/cms_dup.cc b/src/libnml/cms/cms_dup.cc index f97d6228432..38517b81e80 100644 --- a/src/libnml/cms/cms_dup.cc +++ b/src/libnml/cms/cms_dup.cc @@ -39,6 +39,12 @@ extern "C" { CMS_DISPLAY_ASCII_UPDATER::CMS_DISPLAY_ASCII_UPDATER(CMS * _cms_parent): CMS_UPDATER(_cms_parent) { + fprintf(stderr, + "* * * * * * * * * * - - - - - WARNING - - - - - * * * * * * * * * *\n" + "* CMS_DISPLAY_ASCII_UPDATER may not function properly due *\n" + "* to range limitations of some of the update() functions. *\n" + "* * * * * * * * * * - - - - - WARNING - - - - - * * * * * * * * * *\n"); + /* Set pointers to NULL. */ begin_current_string = (char *) NULL; end_current_string = (char *) NULL; @@ -279,36 +285,40 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(bool &x) return (CMS_UPDATE_ERROR); } - update_char((char &)x); + char cx = (char)x; + update_char(cx); + x = (bool)cx; end_current_string[0] = ','; find_next_comma(); return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(char &x) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int8_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(char))) { + if (-1 == check_pointer((char *) &x, sizeof(int8_t))) { return (CMS_UPDATE_ERROR); } - update_char(x); + char cx = (char)x; + update_char(cx); + x = (int8_t)cx; end_current_string[0] = ','; find_next_comma(); return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(char *x, unsigned int len) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int8_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(char) * len)) { + if (-1 == check_pointer((char *) x, sizeof(int8_t) * len)) { return (CMS_UPDATE_ERROR); } unsigned int i; updating_string = 1; for (i = 0; i < len; i++) { - update_char(x[i]); + update_char(reinterpret_cast(x)[i]); if (x[i] == 0) { break; } @@ -321,27 +331,26 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(char *x, unsigned int len) /* Char functions */ -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned char &x) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(uint8_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(unsigned char))) { + if (-1 == check_pointer((char *) &x, sizeof(uint8_t))) { return (CMS_UPDATE_ERROR); } char cx; cx = (char) x; update_char(cx); - x = (unsigned char) x; + x = (uint8_t)cx; end_current_string[0] = ','; find_next_comma(); return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned char *x, - unsigned int len) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(uint8_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(unsigned char) * len)) { + if (-1 == check_pointer((char *) x, sizeof(uint8_t) * len)) { return (CMS_UPDATE_ERROR); } char cx; @@ -350,7 +359,7 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned char *x, for (i = 0; i < len; i++) { cx = (char) x[i]; update_char(cx); - x[i] = (unsigned char) cx; + x[i] = (uint8_t) cx; } end_current_string[0] = ','; find_next_comma(); @@ -359,10 +368,10 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned char *x, /* Short functions */ -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(short int &x) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int16_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(short))) { + if (-1 == check_pointer((char *) &x, sizeof(int16_t))) { return (CMS_UPDATE_ERROR); } @@ -377,24 +386,24 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(short int &x) errno, strerror(errno), end_current_string); return (status = CMS_UPDATE_ERROR); } - if ((number < SHRT_MIN || SHRT_MAX < number) + if ((number < INT16_MIN || INT16_MAX < number) && warning_count < warning_count_max) { warning_count++; rcs_print_error ("CMS_DISPLAY_ASCII_UPDATER: (warning) Number %ld out of range for short(%d,%d)\n", number, SHRT_MIN, SHRT_MAX); } - x = (short) number; + x = (int16_t) number; } find_next_comma(); return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(short *x, unsigned int len) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int16_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(short) * len)) { + if (-1 == check_pointer((char *) x, sizeof(int16_t) * len)) { return (CMS_UPDATE_ERROR); } @@ -406,10 +415,10 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(short *x, unsigned int len) return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned short int &x) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(uint16_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(short))) { + if (-1 == check_pointer((char *) &x, sizeof(uint16_t))) { return (CMS_UPDATE_ERROR); } @@ -429,24 +438,23 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned short int &x) errno, strerror(errno), end_current_string); return (status = CMS_UPDATE_ERROR); } - if (number > USHRT_MAX && warning_count < warning_count_max) { + if (number > UINT16_MAX && warning_count < warning_count_max) { warning_count++; rcs_print_error - ("CMS_DISPLAY_ASCII_UPDATER: Number %ld out of range for unsigned short(0,%d)\n", - number, USHRT_MAX); + ("CMS_DISPLAY_ASCII_UPDATER: Number %ld out of range for uint16_t(0,%d)\n", + number, UINT16_MAX); } - x = (unsigned short) number; + x = (uint16_t) number; } find_next_comma(); return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned short *x, - unsigned int len) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(uint16_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(unsigned short) * len)) { + if (-1 == check_pointer((char *) x, sizeof(uint16_t) * len)) { return (CMS_UPDATE_ERROR); } @@ -460,14 +468,15 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned short *x, /* Int functions */ -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int &x) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int32_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(int))) { + if (-1 == check_pointer((char *) &x, sizeof(int32_t))) { return (CMS_UPDATE_ERROR); } if (encoding) { + // FIXME: Bad range if (x > 9999999 && warning_count < warning_count_max) { warning_count++; rcs_print_error @@ -488,23 +497,23 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int &x) errno, strerror(errno), end_current_string); return (status = CMS_UPDATE_ERROR); } - if ((number < ((long) INT_MIN)) || ((((long) INT_MAX) < number) && (warning_count < warning_count_max))) { + if ((number < ((long) INT32_MIN)) || ((((long) INT32_MAX) < number) && (warning_count < warning_count_max))) { warning_count++; rcs_print_error - ("CMS_DISPLAY_ASCII_UPDATER: (warning) Number %ld out of range for int(%d,%d)\n", - number, INT_MIN, INT_MAX); + ("CMS_DISPLAY_ASCII_UPDATER: (warning) Number %ld out of range for int32_t(%d,%d)\n", + number, INT32_MIN, INT32_MAX); } - x = (int) number; + x = (int32_t) number; } find_next_comma(); return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int *x, unsigned int len) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int32_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(int) * len)) { + if (-1 == check_pointer((char *) x, sizeof(int32_t) * len)) { return (CMS_UPDATE_ERROR); } @@ -516,14 +525,15 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int *x, unsigned int len) return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned int &x) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(uint32_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(unsigned int))) { + if (-1 == check_pointer((char *) &x, sizeof(uint32_t))) { return (CMS_UPDATE_ERROR); } if (encoding) { + // FIXME: Bad range if (x > 9999999 && warning_count < warning_count_max) { warning_count++; rcs_print_error @@ -547,8 +557,8 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned int &x) } if (UINT_MAX < number && warning_count < warning_count_max) { rcs_print_error - ("CMS_DISPLAY_ASCII_UPDATER: Number %ld out of range for unsigned int (0,%u)\n", - number, UINT_MAX); + ("CMS_DISPLAY_ASCII_UPDATER: Number %ld out of range for uint32_t (0,%u)\n", + number, UINT32_MAX); } x = (unsigned int) number; } @@ -557,11 +567,10 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned int &x) return (status); } -CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned int *x, - unsigned int len) +CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(uint32_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, sizeof(unsigned int) * len)) { + if (-1 == check_pointer((char *) x, sizeof(uint32_t) * len)) { return (CMS_UPDATE_ERROR); } diff --git a/src/libnml/cms/cms_dup.hh b/src/libnml/cms/cms_dup.hh index 483f791dc8d..018a7336d09 100644 --- a/src/libnml/cms/cms_dup.hh +++ b/src/libnml/cms/cms_dup.hh @@ -22,23 +22,23 @@ class CMS_DISPLAY_ASCII_UPDATER:public CMS_UPDATER { void find_next_comma(); CMS_STATUS update_char(char &x); CMS_STATUS update(bool &x); - CMS_STATUS update(char &x); - CMS_STATUS update(unsigned char &x); - CMS_STATUS update(short int &x); - CMS_STATUS update(unsigned short int &x); - CMS_STATUS update(int &x); - CMS_STATUS update(unsigned int &x); + CMS_STATUS update(int8_t &x); + CMS_STATUS update(uint8_t &x); + CMS_STATUS update(int16_t &x); + CMS_STATUS update(uint16_t &x); + CMS_STATUS update(int32_t &x); + CMS_STATUS update(uint32_t &x); CMS_STATUS update(int64_t &x); CMS_STATUS update(uint64_t &x); CMS_STATUS update(float &x); CMS_STATUS update(double &x); CMS_STATUS update(long double &x); - CMS_STATUS update(char *x, unsigned int len); - CMS_STATUS update(unsigned char *x, unsigned int len); - CMS_STATUS update(short *x, unsigned int len); - CMS_STATUS update(unsigned short *x, unsigned int len); - CMS_STATUS update(int *x, unsigned int len); - CMS_STATUS update(unsigned int *x, unsigned int len); + CMS_STATUS update(int8_t *x, unsigned int len); + CMS_STATUS update(uint8_t *x, unsigned int len); + CMS_STATUS update(int16_t *x, unsigned int len); + CMS_STATUS update(uint16_t *x, unsigned int len); + CMS_STATUS update(int32_t *x, unsigned int len); + CMS_STATUS update(uint32_t *x, unsigned int len); CMS_STATUS update(int64_t *x, unsigned int len); CMS_STATUS update(uint64_t *x, unsigned int len); CMS_STATUS update(float *x, unsigned int len); diff --git a/src/libnml/cms/cms_up.hh b/src/libnml/cms/cms_up.hh index a0eae7df88e..47757ee7105 100644 --- a/src/libnml/cms/cms_up.hh +++ b/src/libnml/cms/cms_up.hh @@ -39,23 +39,23 @@ struct CMS_POINTER_TABLE_ENTRY { class CMS_UPDATER { public: virtual CMS_STATUS update(bool &x) = 0; - virtual CMS_STATUS update(char &x) = 0; - virtual CMS_STATUS update(unsigned char &x) = 0; - virtual CMS_STATUS update(short int &x) = 0; - virtual CMS_STATUS update(unsigned short int &x) = 0; - virtual CMS_STATUS update(int &x) = 0; - virtual CMS_STATUS update(unsigned int &x) = 0; + virtual CMS_STATUS update(int8_t &x) = 0; + virtual CMS_STATUS update(uint8_t &x) = 0; + virtual CMS_STATUS update(int16_t &x) = 0; + virtual CMS_STATUS update(uint16_t &x) = 0; + virtual CMS_STATUS update(int32_t &x) = 0; + virtual CMS_STATUS update(uint32_t &x) = 0; virtual CMS_STATUS update(int64_t &x) = 0; virtual CMS_STATUS update(uint64_t &x) = 0; virtual CMS_STATUS update(float &x) = 0; virtual CMS_STATUS update(double &x) = 0; virtual CMS_STATUS update(long double &x) = 0; - virtual CMS_STATUS update(char *x, unsigned int len) = 0; - virtual CMS_STATUS update(unsigned char *x, unsigned int len) = 0; - virtual CMS_STATUS update(short *x, unsigned int len) = 0; - virtual CMS_STATUS update(unsigned short *x, unsigned int len) = 0; - virtual CMS_STATUS update(int *x, unsigned int len) = 0; - virtual CMS_STATUS update(unsigned int *x, unsigned int len) = 0; + virtual CMS_STATUS update(int8_t *x, unsigned int len) = 0; + virtual CMS_STATUS update(uint8_t *x, unsigned int len) = 0; + virtual CMS_STATUS update(int16_t *x, unsigned int len) = 0; + virtual CMS_STATUS update(uint16_t *x, unsigned int len) = 0; + virtual CMS_STATUS update(int32_t *x, unsigned int len) = 0; + virtual CMS_STATUS update(uint32_t *x, unsigned int len) = 0; virtual CMS_STATUS update(int64_t *x, unsigned int len) = 0; virtual CMS_STATUS update(uint64_t *x, unsigned int len) = 0; virtual CMS_STATUS update(float *x, unsigned int len) = 0; diff --git a/src/libnml/cms/cms_xup.cc b/src/libnml/cms/cms_xup.cc index 7223fb4e622..6a052a08683 100644 --- a/src/libnml/cms/cms_xup.cc +++ b/src/libnml/cms/cms_xup.cc @@ -336,23 +336,23 @@ CMS_STATUS CMS_XDR_UPDATER::update(bool &x) /* Char functions */ -CMS_STATUS CMS_XDR_UPDATER::update(char &x) +CMS_STATUS CMS_XDR_UPDATER::update(int8_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(char))) { + if (-1 == check_pointer((char *) &x, sizeof(int8_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_char(current_stream, &x) != TRUE) { - rcs_print_error("CMS_XDR_UPDATER: xdr_char failed.\n"); + if (xdr_int8_t(current_stream, &x) != TRUE) { + rcs_print_error("CMS_XDR_UPDATER: xdr_uint8_t failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(char *x, unsigned int len) +CMS_STATUS CMS_XDR_UPDATER::update(int8_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, len * sizeof(char))) { + if (-1 == check_pointer((char *) x, len * sizeof(int8_t))) { return (CMS_UPDATE_ERROR); } @@ -363,23 +363,23 @@ CMS_STATUS CMS_XDR_UPDATER::update(char *x, unsigned int len) return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(unsigned char &x) +CMS_STATUS CMS_XDR_UPDATER::update(uint8_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(char))) { + if (-1 == check_pointer((char *) &x, sizeof(uint8_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_u_char(current_stream, (unsigned char *) &x) != TRUE) { - rcs_print_error("CMS_XDR_UPDATER: xdr_u_char failed.\n"); + if (xdr_uint8_t(current_stream, &x) != TRUE) { + rcs_print_error("CMS_XDR_UPDATER: xdr_uint8_t failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(unsigned char *x, unsigned int len) +CMS_STATUS CMS_XDR_UPDATER::update(uint8_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, len * sizeof(unsigned char))) { + if (-1 == check_pointer((char *) x, len * sizeof(uint8_t))) { return (CMS_UPDATE_ERROR); } @@ -392,61 +392,61 @@ CMS_STATUS CMS_XDR_UPDATER::update(unsigned char *x, unsigned int len) /* SHORT */ -CMS_STATUS CMS_XDR_UPDATER::update(short int &x) +CMS_STATUS CMS_XDR_UPDATER::update(int16_t &x) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) &x, sizeof(short))) { + if (-1 == check_pointer((char *) &x, sizeof(int16_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_short(current_stream, &x) != TRUE) { - rcs_print_error("CMS_XDR_UPDATER: xdr_short failed.\n"); + if (xdr_int16_t(current_stream, &x) != TRUE) { + rcs_print_error("CMS_XDR_UPDATER: xdr_int16_t failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(short *x, unsigned int len) +CMS_STATUS CMS_XDR_UPDATER::update(int16_t *x, unsigned int len) { /* Check to see if the pointers are in the proper range. */ - if (-1 == check_pointer((char *) x, len * sizeof(short))) { + if (-1 == check_pointer((char *) x, len * sizeof(int16_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_vector(current_stream, (char *) x, len, sizeof(short), - (xdrproc_t) xdr_short) != TRUE) { + if (xdr_vector(current_stream, (char *) x, len, sizeof(int16_t), + (xdrproc_t) xdr_int16_t) != TRUE) { rcs_print_error - ("CMS_XDR_UPDATER: xdr_vector(... xdr_short) failed.\n"); + ("CMS_XDR_UPDATER: xdr_vector(... xdr_int16_t) failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(unsigned short int &x) +CMS_STATUS CMS_XDR_UPDATER::update(uint16_t &x) { - if (-1 == check_pointer((char *) &x, sizeof(unsigned short))) { + if (-1 == check_pointer((char *) &x, sizeof(uint16_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_u_short(current_stream, &x) != TRUE) { - rcs_print_error("CMS_XDR_UPDATER: xdr_u_short failed.\n"); + if (xdr_uint16_t(current_stream, &x) != TRUE) { + rcs_print_error("CMS_XDR_UPDATER: xdr_uint16_t failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(unsigned short *x, unsigned int len) +CMS_STATUS CMS_XDR_UPDATER::update(uint16_t *x, unsigned int len) { - if (-1 == check_pointer((char *) x, len * sizeof(unsigned short))) { + if (-1 == check_pointer((char *) x, len * sizeof(uint16_t))) { return (CMS_UPDATE_ERROR); } if (xdr_vector(current_stream, (char *) x, len, - sizeof(unsigned short), (xdrproc_t) xdr_u_short) != TRUE) { + sizeof(uint16_t), (xdrproc_t) xdr_uint16_t) != TRUE) { rcs_print_error - ("CMS_XDR_UPDATER: xdr_vector(... xdr_u_short) failed.\n"); + ("CMS_XDR_UPDATER: xdr_vector(... xdr_uint16_t) failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); @@ -454,57 +454,57 @@ CMS_STATUS CMS_XDR_UPDATER::update(unsigned short *x, unsigned int len) /* INT */ -CMS_STATUS CMS_XDR_UPDATER::update(int &x) +CMS_STATUS CMS_XDR_UPDATER::update(int32_t &x) { - if (-1 == check_pointer((char *) &x, sizeof(int))) { + if (-1 == check_pointer((char *) &x, sizeof(int32_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_int(current_stream, &x) != TRUE) { - rcs_print_error("CMS_XDR_UPDATER: xdr_int failed.\n"); + if (xdr_int32_t(current_stream, &x) != TRUE) { + rcs_print_error("CMS_XDR_UPDATER: xdr_int32_t failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(int *x, unsigned int len) +CMS_STATUS CMS_XDR_UPDATER::update(int32_t *x, unsigned int len) { - if (-1 == check_pointer((char *) x, len * sizeof(int))) { + if (-1 == check_pointer((char *) x, len * sizeof(int32_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_vector(current_stream, (char *) x, len, sizeof(int), - (xdrproc_t) xdr_int) != TRUE) { + if (xdr_vector(current_stream, (char *) x, len, sizeof(int32_t), + (xdrproc_t) xdr_int32_t) != TRUE) { rcs_print_error - ("CMS_XDR_UPDATER: xdr_vector( ... xdr_int) failed.\n"); + ("CMS_XDR_UPDATER: xdr_vector( ... xdr_int32_t) failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(unsigned int &x) +CMS_STATUS CMS_XDR_UPDATER::update(uint32_t &x) { - if (-1 == check_pointer((char *) &x, sizeof(unsigned int))) { + if (-1 == check_pointer((char *) &x, sizeof(uint32_t))) { return (CMS_UPDATE_ERROR); } - if (xdr_u_int(current_stream, &x) != TRUE) { - rcs_print_error("CMS_XDR_UPDATER: xdr_u_int failed.\n"); + if (xdr_uint32_t(current_stream, &x) != TRUE) { + rcs_print_error("CMS_XDR_UPDATER: xdr_uint32_t failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); } -CMS_STATUS CMS_XDR_UPDATER::update(unsigned int *x, unsigned int len) +CMS_STATUS CMS_XDR_UPDATER::update(uint32_t *x, unsigned int len) { - if (-1 == check_pointer((char *) x, len * sizeof(unsigned int))) { + if (-1 == check_pointer((char *) x, len * sizeof(uint32_t))) { return (CMS_UPDATE_ERROR); } if (xdr_vector(current_stream, (char *) x, len, - sizeof(unsigned int), (xdrproc_t) xdr_u_int) != TRUE) { + sizeof(uint32_t), (xdrproc_t) xdr_uint32_t) != TRUE) { rcs_print_error - ("CMS_XDR_UPDATER: xdr_vector(... xdr_u_int) failed.\n"); + ("CMS_XDR_UPDATER: xdr_vector(... xdr_uint32_t) failed.\n"); return (status = CMS_UPDATE_ERROR); } return (status); diff --git a/src/libnml/cms/cms_xup.hh b/src/libnml/cms/cms_xup.hh index 6644bd00e48..91eb876c10e 100644 --- a/src/libnml/cms/cms_xup.hh +++ b/src/libnml/cms/cms_xup.hh @@ -23,23 +23,24 @@ extern "C" { class CMS_XDR_UPDATER:public CMS_UPDATER { public: CMS_STATUS update(bool &x); - CMS_STATUS update(char &x); - CMS_STATUS update(unsigned char &x); - CMS_STATUS update(short int &x); - CMS_STATUS update(unsigned short int &x); - CMS_STATUS update(int &x); - CMS_STATUS update(unsigned int &x); + CMS_STATUS update(int8_t &x); + CMS_STATUS update(uint8_t &x); + CMS_STATUS update(int16_t &x); + CMS_STATUS update(uint16_t &x); + CMS_STATUS update(int32_t &x); + CMS_STATUS update(uint32_t &x); CMS_STATUS update(int64_t &x); CMS_STATUS update(uint64_t &x); CMS_STATUS update(float &x); CMS_STATUS update(double &x); CMS_STATUS update(long double &x); - CMS_STATUS update(char *x, unsigned int len); - CMS_STATUS update(unsigned char *x, unsigned int len); - CMS_STATUS update(short *x, unsigned int len); - CMS_STATUS update(unsigned short *x, unsigned int len); - CMS_STATUS update(int *x, unsigned int len); - CMS_STATUS update(unsigned int *x, unsigned int len); + CMS_STATUS update(char *x, unsigned int len) { return update(reinterpret_cast(x), len); }; + CMS_STATUS update(int8_t *x, unsigned int len); + CMS_STATUS update(uint8_t *x, unsigned int len); + CMS_STATUS update(int16_t *x, unsigned int len); + CMS_STATUS update(uint16_t *x, unsigned int len); + CMS_STATUS update(int32_t *x, unsigned int len); + CMS_STATUS update(uint32_t *x, unsigned int len); CMS_STATUS update(int64_t *x, unsigned int len); CMS_STATUS update(uint64_t *x, unsigned int len); CMS_STATUS update(float *x, unsigned int len);