Skip to content

Commit efe4ef2

Browse files
committed
nml+cms: Replace non-functional 64-bit long int updaters with functional int64 types.
1 parent acff411 commit efe4ef2

9 files changed

Lines changed: 90 additions & 88 deletions

File tree

src/libnml/cms/cms.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ CMS_STATUS CMS::update(unsigned int &x)
13461346
}
13471347
}
13481348

1349-
CMS_STATUS CMS::update(long int &x)
1349+
CMS_STATUS CMS::update(int64_t &x)
13501350
{
13511351
if (NULL != updater) {
13521352
return (updater->update(x));
@@ -1355,7 +1355,7 @@ CMS_STATUS CMS::update(long int &x)
13551355
}
13561356
}
13571357

1358-
CMS_STATUS CMS::update(unsigned long int &x)
1358+
CMS_STATUS CMS::update(uint64_t &x)
13591359
{
13601360
if (NULL != updater) {
13611361
return (updater->update(x));
@@ -1445,7 +1445,7 @@ CMS_STATUS CMS::update(unsigned int *x, unsigned int len)
14451445
}
14461446
}
14471447

1448-
CMS_STATUS CMS::update(long *x, unsigned int len)
1448+
CMS_STATUS CMS::update(int64_t *x, unsigned int len)
14491449
{
14501450
if (NULL != updater) {
14511451
return (updater->update(x, len));
@@ -1454,7 +1454,7 @@ CMS_STATUS CMS::update(long *x, unsigned int len)
14541454
}
14551455
}
14561456

1457-
CMS_STATUS CMS::update(unsigned long *x, unsigned int len)
1457+
CMS_STATUS CMS::update(uint64_t *x, unsigned int len)
14581458
{
14591459
if (NULL != updater) {
14601460
return (updater->update(x, len));

src/libnml/cms/cms.hh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#ifndef CMS_HH
1717
#define CMS_HH
1818

19+
#include <stdint.h>
20+
1921
#ifdef __cplusplus
2022
extern "C" {
2123
#endif
@@ -269,8 +271,8 @@ class CMS {
269271
CMS_STATUS update(unsigned short int &x);
270272
CMS_STATUS update(int &x); /* Used by emc2 */
271273
CMS_STATUS update(unsigned int &x);
272-
CMS_STATUS update(long int &x); /* Used by emc2 */
273-
CMS_STATUS update(unsigned long int &x); /* Used by emc2 */
274+
CMS_STATUS update(int64_t &x); /* Used by emc2 */
275+
CMS_STATUS update(uint64_t &x); /* Used by emc2 */
274276
CMS_STATUS update(float &x);
275277
CMS_STATUS update(double &x); /* Used by emc2 */
276278
CMS_STATUS update(long double &x);
@@ -280,8 +282,8 @@ class CMS {
280282
CMS_STATUS update(unsigned short *x, unsigned int len);
281283
CMS_STATUS update(int *x, unsigned int len); /* Used by emc2 */
282284
CMS_STATUS update(unsigned int *x, unsigned int len);
283-
CMS_STATUS update(long *x, unsigned int len);
284-
CMS_STATUS update(unsigned long *x, unsigned int len);
285+
CMS_STATUS update(int64_t *x, unsigned int len);
286+
CMS_STATUS update(uint64_t *x, unsigned int len);
285287
CMS_STATUS update(float *x, unsigned int len);
286288
CMS_STATUS update(double *x, unsigned int len); /* Used by emc2 */
287289
CMS_STATUS update(long double *x, unsigned int len);

src/libnml/cms/cms_aup.cc

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -569,48 +569,48 @@ CMS_STATUS CMS_ASCII_UPDATER::update(unsigned int *x, unsigned int len)
569569

570570
/* Long functions */
571571

572-
CMS_STATUS CMS_ASCII_UPDATER::update(long int &x)
572+
CMS_STATUS CMS_ASCII_UPDATER::update(int64_t &x)
573573
{
574574
/* Check to see if the pointers are in the proper range. */
575-
if (-1 == check_pointer((char *) &x, sizeof(long))) {
575+
if (-1 == check_pointer((char *) &x, sizeof(int64_t))) {
576576
return (status = CMS_UPDATE_ERROR);
577577
}
578578

579579
if (encoding) {
580-
end_current_string[15] = 0;
581-
sprintf(end_current_string, "%-14ld", x);
582-
if (end_current_string[15] != 0 && warning_count < warning_count_max) {
580+
end_current_string[22] = 0;
581+
sprintf(end_current_string, "%-21ld", x);
582+
if (end_current_string[22] != 0 && warning_count < warning_count_max) {
583583
warning_count++;
584584
rcs_print_error
585-
("CMS_ASCII_UPDATER: (warning) long with value %-14ld caused an overflow\n",
585+
("CMS_ASCII_UPDATER: (warning) int64_t with value %-21ld caused an overflow\n",
586586
x);
587587
}
588-
end_current_string[15] = 0;
588+
end_current_string[22] = 0;
589589
} else {
590-
if (-1 == safe_strlen(end_current_string, 16)) {
590+
if (-1 == safe_strlen(end_current_string, 23)) {
591591
rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n");
592592
return (status = CMS_UPDATE_ERROR);
593593
}
594594
errno = 0;
595-
long number = strtol(end_current_string, (char **) NULL, 10);
595+
int64_t number = strtoll(end_current_string, (char **) NULL, 10);
596596
if (errno != 0) {
597597
rcs_print_error
598-
("CMS_ASCII_UPDATER: Error %d occurred during strtol.\n",
598+
("CMS_ASCII_UPDATER: Error %d occurred during strtoll.\n",
599599
errno);
600600
return (status = CMS_UPDATE_ERROR);
601601
}
602602
x = number;
603603
}
604-
end_current_string += 16;
605-
length_current_string += 16;
604+
end_current_string += 23;
605+
length_current_string += 23;
606606

607607
return (status);
608608
}
609609

610-
CMS_STATUS CMS_ASCII_UPDATER::update(long *x, unsigned int len)
610+
CMS_STATUS CMS_ASCII_UPDATER::update(int64_t *x, unsigned int len)
611611
{
612612
/* Check to see if the pointers are in the proper range. */
613-
if (-1 == check_pointer((char *) x, sizeof(long) * len)) {
613+
if (-1 == check_pointer((char *) x, sizeof(int64_t) * len)) {
614614
return (status = CMS_UPDATE_ERROR);
615615
}
616616

@@ -622,49 +622,49 @@ CMS_STATUS CMS_ASCII_UPDATER::update(long *x, unsigned int len)
622622
return (status);
623623
}
624624

625-
CMS_STATUS CMS_ASCII_UPDATER::update(unsigned long int &x)
625+
CMS_STATUS CMS_ASCII_UPDATER::update(uint64_t &x)
626626
{
627627
/* Check to see if the pointers are in the proper range. */
628-
if (-1 == check_pointer((char *) &x, sizeof(unsigned long))) {
628+
if (-1 == check_pointer((char *) &x, sizeof(uint64_t))) {
629629
return (status = CMS_UPDATE_ERROR);
630630
}
631631

632632
if (encoding) {
633-
end_current_string[15] = 0;
634-
sprintf(end_current_string, "%-14lu", x);
635-
if (end_current_string[15] != 0 && warning_count < warning_count_max) {
633+
end_current_string[22] = 0;
634+
sprintf(end_current_string, "%-21lu", x);
635+
if (end_current_string[22] != 0 && warning_count < warning_count_max) {
636636
warning_count++;
637637
rcs_print_error
638-
("CMS_ASCII_UPDATER: (warning) unsigned long with value %-14ld caused an overflow\n",
638+
("CMS_ASCII_UPDATER: (warning) uint64_t with value %-21ld caused an overflow\n",
639639
x);
640640
}
641-
end_current_string[15] = 0;
641+
end_current_string[22] = 0;
642642
} else {
643-
if (-1 == safe_strlen(end_current_string, 16)) {
643+
if (-1 == safe_strlen(end_current_string, 23)) {
644644
rcs_print_error("CMS_ASCII_UPDATER: String is too long.\n");
645645
return (status = CMS_UPDATE_ERROR);
646646
}
647647
errno = 0;
648-
unsigned long
649-
number = strtoul(end_current_string, (char **) NULL, 10);
648+
uint64_t
649+
number = strtoull(end_current_string, (char **) NULL, 10);
650650
if (errno != 0) {
651651
rcs_print_error
652-
("CMS_ASCII_UPDATER: Error %d:%s occurred during strtoul of(%s).\n",
652+
("CMS_ASCII_UPDATER: Error %d:%s occurred during strtoull of(%s).\n",
653653
errno, strerror(errno), end_current_string);
654654
return (status = CMS_UPDATE_ERROR);
655655
}
656656
x = number;
657657
}
658-
end_current_string += 16;
659-
length_current_string += 16;
658+
end_current_string += 23;
659+
length_current_string += 23;
660660

661661
return (status);
662662
}
663663

664-
CMS_STATUS CMS_ASCII_UPDATER::update(unsigned long *x, unsigned int len)
664+
CMS_STATUS CMS_ASCII_UPDATER::update(uint64_t *x, unsigned int len)
665665
{
666666
/* Check to see if the pointers are in the proper range. */
667-
if (-1 == check_pointer((char *) x, sizeof(unsigned long) * len)) {
667+
if (-1 == check_pointer((char *) x, sizeof(uint64_t) * len)) {
668668
return (status = CMS_UPDATE_ERROR);
669669
}
670670

src/libnml/cms/cms_aup.hh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class CMS_ASCII_UPDATER:public CMS_UPDATER {
2525
CMS_STATUS update(unsigned short int &x);
2626
CMS_STATUS update(int &x);
2727
CMS_STATUS update(unsigned int &x);
28-
CMS_STATUS update(long int &x);
29-
CMS_STATUS update(unsigned long int &x);
28+
CMS_STATUS update(int64_t &x);
29+
CMS_STATUS update(uint64_t &x);
3030
CMS_STATUS update(float &x);
3131
CMS_STATUS update(double &x);
3232
CMS_STATUS update(long double &x);
@@ -36,8 +36,8 @@ class CMS_ASCII_UPDATER:public CMS_UPDATER {
3636
CMS_STATUS update(unsigned short *x, unsigned int len);
3737
CMS_STATUS update(int *x, unsigned int len);
3838
CMS_STATUS update(unsigned int *x, unsigned int len);
39-
CMS_STATUS update(long *x, unsigned int len);
40-
CMS_STATUS update(unsigned long *x, unsigned int len);
39+
CMS_STATUS update(int64_t *x, unsigned int len);
40+
CMS_STATUS update(uint64_t *x, unsigned int len);
4141
CMS_STATUS update(float *x, unsigned int len);
4242
CMS_STATUS update(double *x, unsigned int len);
4343
CMS_STATUS update(long double *x, unsigned int len);

src/libnml/cms/cms_dup.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -575,33 +575,33 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned int *x,
575575

576576
/* Long functions */
577577

578-
CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(long int &x)
578+
CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int64_t &x)
579579
{
580580
/* Check to see if the pointers are in the proper range. */
581-
if (-1 == check_pointer((char *) &x, sizeof(long))) {
581+
if (-1 == check_pointer((char *) &x, sizeof(int64_t))) {
582582
return (CMS_UPDATE_ERROR);
583583
}
584584

585585
if (encoding) {
586-
end_current_string[15] = 0;
586+
end_current_string[22] = 0;
587587
snprintf(end_current_string, max_length_current_string-(end_current_string - begin_current_string), "%+ld,", x);
588-
if (end_current_string[15] != 0 && warning_count < warning_count_max) {
588+
if (end_current_string[22] != 0 && warning_count < warning_count_max) {
589589
warning_count++;
590590
rcs_print_error
591-
("CMS_DISPLAY_ASCII_UPDATER: (warning) long with value %-14ld caused an overflow\n",
591+
("CMS_DISPLAY_ASCII_UPDATER: (warning) int64_t with value %-21ld caused an overflow\n",
592592
x);
593593
}
594-
end_current_string[15] = 0;
594+
end_current_string[22] = 0;
595595
} else {
596596
if (0 == end_current_string[0]) {
597597
x = 0;
598598
return status;
599599
}
600600
errno = 0;
601-
long number = strtol(end_current_string, (char **) NULL, 10);
601+
int64_t number = strtoll(end_current_string, (char **) NULL, 10);
602602
if (errno != 0) {
603603
rcs_print_error
604-
("CMS_DISPLAY_ASCII_UPDATER: Error %d: %s occurred during strtol of(%s).\n",
604+
("CMS_DISPLAY_ASCII_UPDATER: Error %d: %s occurred during strtoll of(%s).\n",
605605
errno, strerror(errno), end_current_string);
606606
return (status = CMS_UPDATE_ERROR);
607607
}
@@ -612,10 +612,10 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(long int &x)
612612
return (status);
613613
}
614614

615-
CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(long *x, unsigned int len)
615+
CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(int64_t *x, unsigned int len)
616616
{
617617
/* Check to see if the pointers are in the proper range. */
618-
if (-1 == check_pointer((char *) x, sizeof(long) * len)) {
618+
if (-1 == check_pointer((char *) x, sizeof(int64_t) * len)) {
619619
return (CMS_UPDATE_ERROR);
620620
}
621621

@@ -627,10 +627,10 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(long *x, unsigned int len)
627627
return (status);
628628
}
629629

630-
CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned long int &x)
630+
CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(uint64_t &x)
631631
{
632632
/* Check to see if the pointers are in the proper range. */
633-
if (-1 == check_pointer((char *) &x, sizeof(unsigned long))) {
633+
if (-1 == check_pointer((char *) &x, sizeof(uint64_t))) {
634634
return (CMS_UPDATE_ERROR);
635635
}
636636

@@ -643,11 +643,11 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned long int &x)
643643
return status;
644644
}
645645
errno = 0;
646-
unsigned long number =
647-
strtoul(end_current_string, (char **) NULL, 10);
646+
uint64_t number =
647+
strtoull(end_current_string, (char **) NULL, 10);
648648
if (errno != 0) {
649649
rcs_print_error
650-
("CMS_DISPLAY_ASCII_UPDATER: Error %d:%s occurred during strtoul of(%s).\n",
650+
("CMS_DISPLAY_ASCII_UPDATER: Error %d:%s occurred during strtoull of(%s).\n",
651651
errno, strerror(errno), end_current_string);
652652
return (status = CMS_UPDATE_ERROR);
653653
}
@@ -658,11 +658,11 @@ CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned long int &x)
658658
return (status);
659659
}
660660

661-
CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(unsigned long *x,
661+
CMS_STATUS CMS_DISPLAY_ASCII_UPDATER::update(uint64_t *x,
662662
unsigned int len)
663663
{
664664
/* Check to see if the pointers are in the proper range. */
665-
if (-1 == check_pointer((char *) x, sizeof(unsigned long) * len)) {
665+
if (-1 == check_pointer((char *) x, sizeof(uint64_t) * len)) {
666666
return (CMS_UPDATE_ERROR);
667667
}
668668

src/libnml/cms/cms_dup.hh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class CMS_DISPLAY_ASCII_UPDATER:public CMS_UPDATER {
2828
CMS_STATUS update(unsigned short int &x);
2929
CMS_STATUS update(int &x);
3030
CMS_STATUS update(unsigned int &x);
31-
CMS_STATUS update(long int &x);
32-
CMS_STATUS update(unsigned long int &x);
31+
CMS_STATUS update(int64_t &x);
32+
CMS_STATUS update(uint64_t &x);
3333
CMS_STATUS update(float &x);
3434
CMS_STATUS update(double &x);
3535
CMS_STATUS update(long double &x);
@@ -39,8 +39,8 @@ class CMS_DISPLAY_ASCII_UPDATER:public CMS_UPDATER {
3939
CMS_STATUS update(unsigned short *x, unsigned int len);
4040
CMS_STATUS update(int *x, unsigned int len);
4141
CMS_STATUS update(unsigned int *x, unsigned int len);
42-
CMS_STATUS update(long *x, unsigned int len);
43-
CMS_STATUS update(unsigned long *x, unsigned int len);
42+
CMS_STATUS update(int64_t *x, unsigned int len);
43+
CMS_STATUS update(uint64_t *x, unsigned int len);
4444
CMS_STATUS update(float *x, unsigned int len);
4545
CMS_STATUS update(double *x, unsigned int len);
4646
CMS_STATUS update(long double *x, unsigned int len);

src/libnml/cms/cms_up.hh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class CMS_UPDATER {
4545
virtual CMS_STATUS update(unsigned short int &x) = 0;
4646
virtual CMS_STATUS update(int &x) = 0;
4747
virtual CMS_STATUS update(unsigned int &x) = 0;
48-
virtual CMS_STATUS update(long int &x) = 0;
49-
virtual CMS_STATUS update(unsigned long int &x) = 0;
48+
virtual CMS_STATUS update(int64_t &x) = 0;
49+
virtual CMS_STATUS update(uint64_t &x) = 0;
5050
virtual CMS_STATUS update(float &x) = 0;
5151
virtual CMS_STATUS update(double &x) = 0;
5252
virtual CMS_STATUS update(long double &x) = 0;
@@ -56,8 +56,8 @@ class CMS_UPDATER {
5656
virtual CMS_STATUS update(unsigned short *x, unsigned int len) = 0;
5757
virtual CMS_STATUS update(int *x, unsigned int len) = 0;
5858
virtual CMS_STATUS update(unsigned int *x, unsigned int len) = 0;
59-
virtual CMS_STATUS update(long *x, unsigned int len) = 0;
60-
virtual CMS_STATUS update(unsigned long *x, unsigned int len) = 0;
59+
virtual CMS_STATUS update(int64_t *x, unsigned int len) = 0;
60+
virtual CMS_STATUS update(uint64_t *x, unsigned int len) = 0;
6161
virtual CMS_STATUS update(float *x, unsigned int len) = 0;
6262
virtual CMS_STATUS update(double *x, unsigned int len) = 0;
6363
virtual CMS_STATUS update(long double *x, unsigned int len) = 0;

0 commit comments

Comments
 (0)