@@ -79,8 +79,7 @@ static void vuart_print_char(struct vcpu *v, char c)
struct domain *d = v->domain;
struct vuart *uart = &d->arch.vuart;
- /* Accept only printable characters, newline, and horizontal tab. */
- if ( !isprint(c) && (c != '\n') && (c != '\t') )
+ if ( !isconsole(c) )
return ;
spin_lock(&uart->lock);
@@ -561,8 +561,7 @@ static int cf_check hvm_print_line(
if ( dir != IOREQ_WRITE )
return X86EMUL_UNHANDLEABLE;
- /* Accept only printable characters, newline, and horizontal tab. */
- if ( !isprint(c) && (c != '\n') && (c != '\t') )
+ if ( !isconsole(c) )
return X86EMUL_OKAY;
spin_lock(&cd->pbuf_lock);
@@ -674,7 +674,7 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer,
c = *kin++;
if ( c == '\n' )
break;
- if ( isprint(c) || c == '\t' )
+ if ( isconsole(c) )
*kout++ = c;
} while ( --kcount > 0 );
@@ -4,6 +4,8 @@
/*
* NOTE! This ctype does not handle EOF like the standard C
* library is required to.
+ *
+ * See Rule 21.13 in docs/misra/rules.rst.
*/
#define _U 0x01 /* upper */
@@ -30,6 +32,7 @@ extern const unsigned char _ctype[];
#define isspace(c) ((__ismask(c)&(_S)) != 0)
#define isupper(c) ((__ismask(c)&(_U)) != 0)
#define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0)
+#define isconsole(c) (isprint(c) || c == '\n' || c == '\t')
#define isascii(c) (((unsigned char)(c))<=0x7f)
#define toascii(c) (((unsigned char)(c))&0x7f)