aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-01-08 12:30:49 +0000
committerRon Yorston <rmy@pobox.com>2020-01-08 12:30:49 +0000
commita9271a8e97e6e7be5285330d5f19352decabf807 (patch)
treebf3c4464c369a15a46454792dac167505f74769f /miscutils
parentb0b7ab792bc1f45963f4b84b94faaf05054e1613 (diff)
parent9ec836c033fc6e55e80f3309b3e05acdf09bb297 (diff)
downloadbusybox-w32-a9271a8e97e6e7be5285330d5f19352decabf807.tar.gz
busybox-w32-a9271a8e97e6e7be5285330d5f19352decabf807.tar.bz2
busybox-w32-a9271a8e97e6e7be5285330d5f19352decabf807.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c28
-rw-r--r--miscutils/hdparm.c2
2 files changed, 21 insertions, 9 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 7ac30dd53..c7246ea1a 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -844,10 +844,10 @@ struct globals {
844# error Strange INT_MAX 844# error Strange INT_MAX
845#endif 845#endif
846 846
847#if UINT_MAX == 4294967295 847#if UINT_MAX == 4294967295U
848# define BC_MAX_SCALE_STR "4294967295" 848# define BC_MAX_SCALE_STR "4294967295"
849# define BC_MAX_STRING_STR "4294967294" 849# define BC_MAX_STRING_STR "4294967294"
850#elif UINT_MAX == 18446744073709551615 850#elif UINT_MAX == 18446744073709551615U
851# define BC_MAX_SCALE_STR "18446744073709551615" 851# define BC_MAX_SCALE_STR "18446744073709551615"
852# define BC_MAX_STRING_STR "18446744073709551614" 852# define BC_MAX_STRING_STR "18446744073709551614"
853#else 853#else
@@ -1465,7 +1465,10 @@ static ssize_t bc_num_cmp(BcNum *a, BcNum *b)
1465 b_int = BC_NUM_INT(b); 1465 b_int = BC_NUM_INT(b);
1466 a_int -= b_int; 1466 a_int -= b_int;
1467 1467
1468 if (a_int != 0) return (ssize_t) a_int; 1468 if (a_int != 0) {
1469 if (neg) return - (ssize_t) a_int;
1470 return (ssize_t) a_int;
1471 }
1469 1472
1470 a_max = (a->rdx > b->rdx); 1473 a_max = (a->rdx > b->rdx);
1471 if (a_max) { 1474 if (a_max) {
@@ -4973,7 +4976,9 @@ static void dc_parse_string(void)
4973 xc_parse_pushInst_and_Index(XC_INST_STR, len); 4976 xc_parse_pushInst_and_Index(XC_INST_STR, len);
4974 bc_vec_push(&G.prog.strs, &str); 4977 bc_vec_push(&G.prog.strs, &str);
4975 4978
4976 // Explanation needed here 4979 // Add an empty function so that if zdc_program_execStr ever needs to
4980 // parse the string into code (from the 'x' command) there's somewhere
4981 // to store the bytecode.
4977 xc_program_add_fn(); 4982 xc_program_add_fn();
4978 p->func = xc_program_func(p->fidx); 4983 p->func = xc_program_func(p->fidx);
4979 4984
@@ -5454,11 +5459,13 @@ static void xc_program_printString(const char *str)
5454 char *n; 5459 char *n;
5455 5460
5456 c = *str++; 5461 c = *str++;
5457 n = strchr(esc, c); // note: c can be NUL 5462 n = strchr(esc, c); // note: if c is NUL, n = \0 at end of esc
5458 if (!n) { 5463 if (!n || !c) {
5459 // Just print the backslash and following character 5464 // Just print the backslash and following character
5460 bb_putchar('\\'); 5465 bb_putchar('\\');
5461 ++G.prog.nchars; 5466 ++G.prog.nchars;
5467 // But if we're at the end of the string, stop
5468 if (!c) break;
5462 } else { 5469 } else {
5463 if (n - esc == 0) // "\n" ? 5470 if (n - esc == 0) // "\n" ?
5464 G.prog.nchars = SIZE_MAX; 5471 G.prog.nchars = SIZE_MAX;
@@ -6398,7 +6405,11 @@ static BC_STATUS zdc_program_asciify(void)
6398 str = xzalloc(2); 6405 str = xzalloc(2);
6399 str[0] = c; 6406 str[0] = c;
6400 //str[1] = '\0'; - already is 6407 //str[1] = '\0'; - already is
6401 bc_vec_push(&G.prog.strs, &str); 6408 idx = bc_vec_push(&G.prog.strs, &str);
6409 // Add an empty function so that if zdc_program_execStr ever needs to
6410 // parse the string into code (from the 'x' command) there's somewhere
6411 // to store the bytecode.
6412 xc_program_add_fn();
6402 dup: 6413 dup:
6403 res.t = XC_RESULT_STR; 6414 res.t = XC_RESULT_STR;
6404 res.d.id.idx = idx; 6415 res.d.id.idx = idx;
@@ -6521,7 +6532,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond)
6521 if (s || !BC_PROG_STR(n)) goto exit; 6532 if (s || !BC_PROG_STR(n)) goto exit;
6522 sidx = n->rdx; 6533 sidx = n->rdx;
6523 } else 6534 } else
6524 goto exit; 6535 goto exit_nopop;
6525 } 6536 }
6526 6537
6527 fidx = sidx + BC_PROG_REQ_FUNCS; 6538 fidx = sidx + BC_PROG_REQ_FUNCS;
@@ -6561,6 +6572,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond)
6561 RETURN_STATUS(BC_STATUS_SUCCESS); 6572 RETURN_STATUS(BC_STATUS_SUCCESS);
6562 exit: 6573 exit:
6563 bc_vec_pop(&G.prog.results); 6574 bc_vec_pop(&G.prog.results);
6575 exit_nopop:
6564 RETURN_STATUS(s); 6576 RETURN_STATUS(s);
6565} 6577}
6566#define zdc_program_execStr(...) (zdc_program_execStr(__VA_ARGS__) COMMA_SUCCESS) 6578#define zdc_program_execStr(...) (zdc_program_execStr(__VA_ARGS__) COMMA_SUCCESS)
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index b453efba9..beabb1ad5 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -996,7 +996,7 @@ static void identify(uint16_t *val)
996 /* check Endian of capacity bytes */ 996 /* check Endian of capacity bytes */
997 nn = val[LCYLS_CUR] * val[LHEADS_CUR] * val[LSECTS_CUR]; 997 nn = val[LCYLS_CUR] * val[LHEADS_CUR] * val[LSECTS_CUR];
998 oo = (uint32_t)val[CAPACITY_LSB] << 16 | val[CAPACITY_MSB]; 998 oo = (uint32_t)val[CAPACITY_LSB] << 16 | val[CAPACITY_MSB];
999 if (abs(mm - nn) > abs(oo - nn)) 999 if (abs((int)(mm - nn)) > abs((int)(oo - nn)))
1000 mm = oo; 1000 mm = oo;
1001 } 1001 }
1002 printf("\tCHS current addressable sectors:%11u\n", mm); 1002 printf("\tCHS current addressable sectors:%11u\n", mm);