mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
software/bios/readline: Use unsigned int for small numbers
There is no need to use "unsigned long" for small numbers related to the number of characters in a line. Use "unsigned int" instead. This allows us to drop the casts when calling putnstr(), and fixes compiler warnings on 64-bit for callsites where the casts were missing: warning: field precision specifier '.*' expects argument of type 'int', but argument 2 has type 'long unsigned int' Reported-by: Gabriel Somlo <gsomlo@gmail.com> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
This commit is contained in:
parent
ab8cee1b5e
commit
5474f563c8
2 changed files with 10 additions and 10 deletions
|
@ -150,10 +150,10 @@ void hist_init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void cread_add_char(char ichar, int insert, unsigned long *num,
|
||||
unsigned long *eol_num, char *buf, unsigned long len)
|
||||
static void cread_add_char(char ichar, int insert, unsigned int *num,
|
||||
unsigned int *eol_num, char *buf, unsigned int len)
|
||||
{
|
||||
unsigned long wlen;
|
||||
unsigned int wlen;
|
||||
|
||||
if (insert || *num == *eol_num) {
|
||||
if (*eol_num > len - 1) {
|
||||
|
@ -186,9 +186,9 @@ static void cread_add_char(char ichar, int insert, unsigned long *num,
|
|||
|
||||
int readline(char *buf, int len)
|
||||
{
|
||||
unsigned long num = 0;
|
||||
unsigned long eol_num = 0;
|
||||
unsigned long wlen;
|
||||
unsigned int num = 0;
|
||||
unsigned int eol_num = 0;
|
||||
unsigned int wlen;
|
||||
int insert = 1;
|
||||
char ichar;
|
||||
|
||||
|
@ -254,7 +254,7 @@ int readline(char *buf, int len)
|
|||
wlen = eol_num - num - 1;
|
||||
if (wlen) {
|
||||
memmove(&buf[num], &buf[num+1], wlen);
|
||||
putnstr(buf + num, (int)wlen);
|
||||
putnstr(buf + num, wlen);
|
||||
}
|
||||
|
||||
getcmd_putch(' ');
|
||||
|
@ -286,7 +286,7 @@ int readline(char *buf, int len)
|
|||
num--;
|
||||
memmove(buf + num, buf + num + 1, wlen);
|
||||
getcmd_putch(CTL_BACKSPACE);
|
||||
putnstr(buf + num, (int)wlen);
|
||||
putnstr(buf + num, wlen);
|
||||
getcmd_putch(' ');
|
||||
do {
|
||||
getcmd_putch(CTL_BACKSPACE);
|
||||
|
@ -298,7 +298,7 @@ int readline(char *buf, int len)
|
|||
if (num < eol_num) {
|
||||
wlen = eol_num - num;
|
||||
memmove(buf + num, buf + num + 1, wlen);
|
||||
putnstr(buf + num, (int)(wlen - 1));
|
||||
putnstr(buf + num, wlen - 1);
|
||||
getcmd_putch(' ');
|
||||
do {
|
||||
getcmd_putch(CTL_BACKSPACE);
|
||||
|
|
|
@ -72,7 +72,7 @@ struct esc_cmds {
|
|||
#define REFRESH_TO_EOL() { \
|
||||
if (num < eol_num) { \
|
||||
wlen = eol_num - num; \
|
||||
putnstr(buf + num, (int)wlen); \
|
||||
putnstr(buf + num, wlen); \
|
||||
num = eol_num; \
|
||||
} \
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue