mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-23 15:51:07 +08:00
cpukit/libmisc/shell: Correct comparisons of different signedness
The GCC warning -Wsign-compare flagged these instances of comparing signed and unsigned types. A common pair was size_t and int.
This commit is contained in:
committed by
Amar Takhar
parent
fc6cc44de9
commit
3c2592be04
@@ -39,7 +39,7 @@ static unsigned rtems_shell_df_parse_size(const char *str)
|
||||
{
|
||||
unsigned result;
|
||||
char suffix;
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
if (sscanf(str, "%d%c", &result, &suffix) == 2)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ static unsigned rtems_shell_df_parse_size(const char *str)
|
||||
static char *rtems_shell_df_humanize_size(uint64_t block_size, char *buf,
|
||||
size_t size)
|
||||
{
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
|
||||
while (block_size >= 1024 && i < sizeof(suffixes) / sizeof(suffixes[0]) - 1)
|
||||
{
|
||||
|
||||
@@ -354,7 +354,7 @@ static int shell_drvmgr_translate(int argc, char *argv[])
|
||||
rc = drvmgr_translate((struct drvmgr_dev *)obj, up | rev, (void *)src, &dst);
|
||||
if (rc == 0)
|
||||
printf(" Address %p could not be translated\n", (void *)src);
|
||||
else if (rc == 0xffffffff)
|
||||
else if (rc == (int) 0xffffffffU)
|
||||
printf(" %p => %p (no translation required)\n", (void *)src, dst);
|
||||
else
|
||||
printf(" %p => %p (map size 0x%x)\n", (void *)src, dst, rc);
|
||||
|
||||
@@ -213,7 +213,7 @@ int flashdev_shell_read(
|
||||
|
||||
/* Print buffer out in 32bit blocks */
|
||||
printf("Reading %s at 0x%08x for 0x%x bytes\n", dev_path, address, bytes);
|
||||
for (int i = 0; i < (bytes/4); i++) {
|
||||
for (size_t i = 0; i < (bytes/4); i++) {
|
||||
printf("%08x ", ((uint32_t*)buffer)[i]);
|
||||
if ((i+1)%4 == 0) {
|
||||
printf("\n");
|
||||
|
||||
@@ -149,7 +149,7 @@ static int rtems_shell_help(
|
||||
if (!col){
|
||||
col = printf(" %s",topic->topic);
|
||||
} else {
|
||||
if ((col+strlen(topic->topic)+2)>(cols - 2)){
|
||||
if ((col+(int)strlen(topic->topic)+2)>(cols - 2)){
|
||||
printf("\n");
|
||||
col = printf(" %s",topic->topic);
|
||||
} else {
|
||||
@@ -165,7 +165,7 @@ static int rtems_shell_help(
|
||||
shell_cmd = rtems_shell_first_cmd;
|
||||
while (shell_cmd) {
|
||||
size_t len = strlen(shell_cmd->name);
|
||||
if (len > indent) {
|
||||
if ((int)len > indent) {
|
||||
indent = len;
|
||||
}
|
||||
shell_cmd = shell_cmd->next;
|
||||
|
||||
@@ -54,7 +54,7 @@ rtems_i2cset_shell_main(int argc, char *argv[])
|
||||
/* Necessary: data-address and values. This will be a bit more. */
|
||||
uint8_t writebuff[argc];
|
||||
size_t len;
|
||||
size_t i;
|
||||
int i;
|
||||
i2c_msg msgs[] = {{
|
||||
.flags = 0,
|
||||
.buf = writebuff,
|
||||
|
||||
@@ -516,8 +516,12 @@ display(rtems_shell_ls_globals* globals, FTSENT *p, FTSENT *list)
|
||||
DISPLAY d;
|
||||
FTSENT *cur;
|
||||
NAMES *np;
|
||||
u_int64_t btotal, stotal, maxblock, maxsize;
|
||||
int maxinode, maxnlink, maxmajor, maxminor;
|
||||
u_int64_t btotal, stotal, maxsize;
|
||||
blkcnt_t maxblock;
|
||||
ino_t maxinode;
|
||||
rtems_device_major_number maxmajor;
|
||||
rtems_device_minor_number maxminor;
|
||||
int maxnlink;
|
||||
int bcfile, entries, flen, glen, ulen, maxflags, maxgroup, maxlen;
|
||||
int maxuser, needstats;
|
||||
const char *user, *group;
|
||||
@@ -666,7 +670,7 @@ display(rtems_shell_ls_globals* globals, FTSENT *p, FTSENT *list)
|
||||
}
|
||||
d.s_flags = maxflags;
|
||||
d.s_group = maxgroup;
|
||||
(void)snprintf(buf, sizeof(buf), "%u", maxinode);
|
||||
(void)snprintf(buf, sizeof(buf), "%llu", maxinode);
|
||||
d.s_inode = strlen(buf);
|
||||
(void)snprintf(buf, sizeof(buf), "%u", maxnlink);
|
||||
d.s_nlink = strlen(buf);
|
||||
|
||||
@@ -360,7 +360,7 @@ static int rtems_shell_line_editor(
|
||||
|
||||
extended_key = rtems_shell_getchar(in);
|
||||
|
||||
if (extended_key == EOF)
|
||||
if ((int)extended_key == EOF)
|
||||
return -2;
|
||||
|
||||
c = extended_key & RTEMS_SHELL_KEYS_NORMAL_MASK;
|
||||
@@ -451,7 +451,7 @@ static int rtems_shell_line_editor(
|
||||
|
||||
case 4: /* Control-D */
|
||||
if (strlen(line)) {
|
||||
if (col < strlen(line)) {
|
||||
if (col < (int)strlen(line)) {
|
||||
rtems_shell_move_left(line + col, 1);
|
||||
if (out != NULL) {
|
||||
int bs;
|
||||
@@ -620,7 +620,7 @@ static int rtems_shell_line_editor(
|
||||
if (col > 0)
|
||||
{
|
||||
char tmp;
|
||||
if (col == strlen(line)) {
|
||||
if (col == (int)strlen(line)) {
|
||||
col--;
|
||||
if (out != NULL)
|
||||
fprintf(out,"\b");
|
||||
@@ -643,7 +643,7 @@ static int rtems_shell_line_editor(
|
||||
/* strlen() returns size_t but fprintf("%*...") below requires
|
||||
* int! */
|
||||
int clen = (int) strlen (line);
|
||||
int bs;
|
||||
size_t bs;
|
||||
|
||||
rtems_shell_move_left(line, col);
|
||||
if (out != NULL) {
|
||||
@@ -1105,7 +1105,7 @@ static bool shell_main_loop(
|
||||
}
|
||||
|
||||
if (cmd_argv && cmds[0]) {
|
||||
size_t cmd;
|
||||
ssize_t cmd;
|
||||
|
||||
memset (cmds[0], 0, cmd_count * RTEMS_SHELL_CMD_SIZE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user