arch/sim: Ensure all host printf end with \r\n

Since simulator switch console to raw mode, we have to add \r manually
This commit is contained in:
Xiang Xiao 2020-02-24 17:17:16 +08:00 committed by Gregory Nutt
parent 9cd188e3c7
commit 96adb827a3
4 changed files with 37 additions and 41 deletions

View File

@ -113,10 +113,10 @@ void up_assert(const uint8_t *filename, int line)
/* Show the location of the failed assertion */ /* Show the location of the failed assertion */
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
fprintf(stderr, "CPU%d: Assertion failed at file:%s line: %d\n", fprintf(stderr, "CPU%d: Assertion failed at file:%s line: %d\r\n",
up_cpu_index(), filename, line); up_cpu_index(), filename, line);
#else #else
fprintf(stderr, "Assertion failed at file:%s line: %d\n", fprintf(stderr, "Assertion failed at file:%s line: %d\r\n",
filename, line); filename, line);
#endif #endif

View File

@ -115,9 +115,9 @@ static struct rtentry ghostroute;
static inline void dump_ethhdr(const char *msg, unsigned char *buf, static inline void dump_ethhdr(const char *msg, unsigned char *buf,
int buflen) int buflen)
{ {
printf("TAPDEV: %s %d bytes\n", msg, buflen); printf("TAPDEV: %s %d bytes\r\n", msg, buflen);
printf(" %02x:%02x:%02x:%02x:%02x:%02x " printf(" %02x:%02x:%02x:%02x:%02x:%02x "
"%02x:%02x:%02x:%02x:%02x:%02x %02x%02x\n", "%02x:%02x:%02x:%02x:%02x:%02x %02x%02x\r\n",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
#ifdef CONFIG_ENDIAN_BIG #ifdef CONFIG_ENDIAN_BIG
@ -178,7 +178,7 @@ void tapdev_init(void)
gtapdevfd = open(DEVTAP, O_RDWR, 0644); gtapdevfd = open(DEVTAP, O_RDWR, 0644);
if (gtapdevfd < 0) if (gtapdevfd < 0)
{ {
printf("TAPDEV: open failed: %d\n", -gtapdevfd); printf("TAPDEV: open failed: %d\r\n", -gtapdevfd);
return; return;
} }
@ -189,7 +189,7 @@ void tapdev_init(void)
ret = ioctl(gtapdevfd, TUNSETIFF, (unsigned long) &ifr); ret = ioctl(gtapdevfd, TUNSETIFF, (unsigned long) &ifr);
if (ret < 0) if (ret < 0)
{ {
printf("TAPDEV: ioctl failed: %d\n", -ret); printf("TAPDEV: ioctl failed: %d\r\n", -ret);
return; return;
} }
@ -205,7 +205,7 @@ void tapdev_init(void)
sockfd = socket(AF_INET, SOCK_DGRAM, 0); sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0) if (sockfd < 0)
{ {
printf("TAPDEV: Can't open socket: %d\n", -sockfd); printf("TAPDEV: Can't open socket: %d\r\n", -sockfd);
return; return;
} }
@ -219,7 +219,7 @@ void tapdev_init(void)
if (ret < 0) if (ret < 0)
{ {
printf("TAPDEV: ioctl failed (can't add interface %s to " printf("TAPDEV: ioctl failed (can't add interface %s to "
"bridge %s): %d\n", "bridge %s): %d\r\n",
gdevname, CONFIG_SIM_NET_BRIDGE_DEVICE, -ret); gdevname, CONFIG_SIM_NET_BRIDGE_DEVICE, -ret);
} }
@ -266,7 +266,7 @@ unsigned int tapdev_read(unsigned char *buf, unsigned int buflen)
ret = read(gtapdevfd, buf, buflen); ret = read(gtapdevfd, buf, buflen);
if (ret < 0) if (ret < 0)
{ {
printf("TAPDEV: read failed: %d\n", -ret); printf("TAPDEV: read failed: %d\r\n", -ret);
return 0; return 0;
} }
@ -278,12 +278,12 @@ void tapdev_send(unsigned char *buf, unsigned int buflen)
{ {
int ret; int ret;
#ifdef TAPDEV_DEBUG #ifdef TAPDEV_DEBUG
printf("tapdev_send: sending %d bytes\n", buflen); printf("tapdev_send: sending %d bytes\r\n", buflen);
gdrop++; gdrop++;
if (gdrop % 8 == 7) if (gdrop % 8 == 7)
{ {
printf("TAPDEV: Dropped a packet!\n"); printf("TAPDEV: Dropped a packet!\r\n");
return; return;
} }
#endif #endif
@ -291,7 +291,7 @@ void tapdev_send(unsigned char *buf, unsigned int buflen)
ret = write(gtapdevfd, buf, buflen); ret = write(gtapdevfd, buf, buflen);
if (ret < 0) if (ret < 0)
{ {
printf("TAPDEV: write failed: %d", -ret); printf("TAPDEV: write failed: %d\r\n", -ret);
exit(1); exit(1);
} }
@ -313,7 +313,7 @@ void tapdev_ifup(in_addr_t ifaddr)
sockfd = socket(AF_INET, SOCK_DGRAM, 0); sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0) if (sockfd < 0)
{ {
printf("TAPDEV: Can't open socket: %d\n", -sockfd); printf("TAPDEV: Can't open socket: %d\r\n", -sockfd);
return; return;
} }
@ -324,7 +324,7 @@ void tapdev_ifup(in_addr_t ifaddr)
ret = ioctl(sockfd, SIOCGIFFLAGS, (unsigned long)&ifr); ret = ioctl(sockfd, SIOCGIFFLAGS, (unsigned long)&ifr);
if (ret < 0) if (ret < 0)
{ {
printf("TAPDEV: ioctl failed (can't get interface flags): %d\n", -ret); printf("TAPDEV: ioctl failed (can't get interface flags): %d\r\n", -ret);
close(sockfd); close(sockfd);
return; return;
} }
@ -333,7 +333,7 @@ void tapdev_ifup(in_addr_t ifaddr)
ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&ifr); ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&ifr);
if (ret < 0) if (ret < 0)
{ {
printf("TAPDEV: ioctl failed (can't set interface flags): %d\n", -ret); printf("TAPDEV: ioctl failed (can't set interface flags): %d\r\n", -ret);
close(sockfd); close(sockfd);
return; return;
} }
@ -354,7 +354,7 @@ void tapdev_ifup(in_addr_t ifaddr)
ret = ioctl(sockfd, SIOCADDRT, (unsigned long)&ghostroute); ret = ioctl(sockfd, SIOCADDRT, (unsigned long)&ghostroute);
if (ret < 0) if (ret < 0)
{ {
printf("TAPDEV: ioctl failed (can't add host route): %d\n", -ret); printf("TAPDEV: ioctl failed (can't add host route): %d\r\n", -ret);
close(sockfd); close(sockfd);
return; return;
} }
@ -376,14 +376,14 @@ void tapdev_ifdown(void)
sockfd = socket(AF_INET, SOCK_DGRAM, 0); sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0) if (sockfd < 0)
{ {
printf("TAPDEV: Can't open socket: %d\n", -sockfd); printf("TAPDEV: Can't open socket: %d\r\n", -sockfd);
return; return;
} }
ret = ioctl(sockfd, SIOCDELRT, (unsigned long)&ghostroute); ret = ioctl(sockfd, SIOCDELRT, (unsigned long)&ghostroute);
if (ret < 0) if (ret < 0)
{ {
printf("TAPDEV: ioctl failed (can't delete host route): %d\n", -ret); printf("TAPDEV: ioctl failed (can't delete host route): %d\r\n", -ret);
} }
close(sockfd); close(sockfd);

View File

@ -126,7 +126,7 @@ void netdriver_setmacaddr(unsigned char *macaddr);
static void error_exit(char *message) static void error_exit(char *message)
{ {
printf("error_exit: %s", message); printf("error_exit: %s\r\n", message);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -142,7 +142,7 @@ static void init_pcap(struct in_addr addr)
while (interfaces != NULL) while (interfaces != NULL)
{ {
printf("init_pcap: found interface: %s\n", interfaces->description); printf("init_pcap: found interface: %s\r\n", interfaces->description);
if (interfaces->addresses != NULL && if (interfaces->addresses != NULL &&
interfaces->addresses->addr != NULL && interfaces->addresses->addr != NULL &&
@ -151,7 +151,7 @@ static void init_pcap(struct in_addr addr)
struct in_addr interface_addr; struct in_addr interface_addr;
interface_addr = interface_addr =
((struct sockaddr_in *)interfaces->addresses->addr)->sin_addr; ((struct sockaddr_in *)interfaces->addresses->addr)->sin_addr;
printf("init_pcap: with address: %s\n", inet_ntoa(interface_addr)); printf("init_pcap: with address: %s\r\n", inet_ntoa(interface_addr));
if (interface_addr.s_addr == addr.s_addr) if (interface_addr.s_addr == addr.s_addr)
{ {
@ -164,7 +164,7 @@ static void init_pcap(struct in_addr addr)
if (interfaces == NULL) if (interfaces == NULL)
{ {
error_exit("No interface found with IP address\n"); error_exit("No interface found with IP address");
} }
pcap = pcap_open_live(interfaces->name, NETDEV_BUFSIZE, 0, -1, error); pcap = pcap_open_live(interfaces->name, NETDEV_BUFSIZE, 0, -1, error);
@ -184,7 +184,7 @@ static void set_ethaddr(struct in_addr addr)
GAA_FLAG_SKIP_DNS_SERVER, GAA_FLAG_SKIP_DNS_SERVER,
NULL, NULL, &size) != ERROR_BUFFER_OVERFLOW) NULL, NULL, &size) != ERROR_BUFFER_OVERFLOW)
{ {
error_exit("error on access to adapter list size\n"); error_exit("error on access to adapter list size");
} }
adapters = alloca(size); adapters = alloca(size);
@ -194,7 +194,7 @@ static void set_ethaddr(struct in_addr addr)
GAA_FLAG_SKIP_DNS_SERVER, GAA_FLAG_SKIP_DNS_SERVER,
NULL, adapters, &size) != ERROR_SUCCESS) NULL, adapters, &size) != ERROR_SUCCESS)
{ {
error_exit("error on access to adapter list\n"); error_exit("error on access to adapter list");
} }
while (adapters != NULL) while (adapters != NULL)
@ -202,7 +202,7 @@ static void set_ethaddr(struct in_addr addr)
char buffer[256]; char buffer[256];
WideCharToMultiByte(CP_ACP, 0, adapters->Description, -1, WideCharToMultiByte(CP_ACP, 0, adapters->Description, -1,
buffer, sizeof(buffer), NULL, NULL); buffer, sizeof(buffer), NULL, NULL);
printf("set_ethaddr: found adapter: %s\n", buffer); printf("set_ethaddr: found adapter: %s\r\n", buffer);
if (adapters->FirstUnicastAddress != NULL && if (adapters->FirstUnicastAddress != NULL &&
adapters->FirstUnicastAddress->Address.lpSockaddr != NULL && adapters->FirstUnicastAddress->Address.lpSockaddr != NULL &&
@ -213,18 +213,18 @@ static void set_ethaddr(struct in_addr addr)
adapter_addr = adapter_addr =
((struct sockaddr_in *)adapters->FirstUnicastAddress->Address. ((struct sockaddr_in *)adapters->FirstUnicastAddress->Address.
lpSockaddr)->sin_addr; lpSockaddr)->sin_addr;
printf("set_ethaddr: with address: %s\n", inet_ntoa(adapter_addr)); printf("set_ethaddr: with address: %s\r\n", inet_ntoa(adapter_addr));
if (adapter_addr.s_addr == addr.s_addr) if (adapter_addr.s_addr == addr.s_addr)
{ {
if (adapters->PhysicalAddressLength != 6) if (adapters->PhysicalAddressLength != 6)
{ {
error_exit error_exit
("ip addr specified does not belong to an ethernet card\n"); ("ip addr specified does not belong to an ethernet card");
} }
printf printf
("set_ethaddr: ethernetaddr: %02X-%02X-%02X-%02X-%02X-%02X\n", ("set_ethaddr: ethernetaddr: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
adapters->PhysicalAddress[0], adapters->PhysicalAddress[1], adapters->PhysicalAddress[0], adapters->PhysicalAddress[1],
adapters->PhysicalAddress[2], adapters->PhysicalAddress[3], adapters->PhysicalAddress[2], adapters->PhysicalAddress[3],
adapters->PhysicalAddress[4], adapters->PhysicalAddress[5]); adapters->PhysicalAddress[4], adapters->PhysicalAddress[5]);
@ -239,7 +239,7 @@ static void set_ethaddr(struct in_addr addr)
if (adapters == NULL) if (adapters == NULL)
{ {
error_exit("No adaptor found with IP address\n"); error_exit("No adaptor found with IP address");
} }
} }
@ -253,7 +253,7 @@ void wpcap_init(void)
FARPROC dlladdr; FARPROC dlladdr;
addr.s_addr = htonl(WCAP_IPADDR); addr.s_addr = htonl(WCAP_IPADDR);
printf("wpcap_init: IP address: %s\n", inet_ntoa(addr)); printf("wpcap_init: IP address: %s\r\n", inet_ntoa(addr));
wpcap = LoadLibrary("wpcap.dll"); wpcap = LoadLibrary("wpcap.dll");
dlladdr = GetProcAddress(wpcap, "pcap_findalldevs"); dlladdr = GetProcAddress(wpcap, "pcap_findalldevs");
@ -271,7 +271,7 @@ void wpcap_init(void)
if (pcap_findalldevs == NULL || pcap_open_live == NULL || if (pcap_findalldevs == NULL || pcap_open_live == NULL ||
pcap_next_ex == NULL || pcap_sendpacket == NULL) pcap_next_ex == NULL || pcap_sendpacket == NULL)
{ {
error_exit("error on access to winpcap library\n"); error_exit("error on access to winpcap library");
} }
init_pcap(addr); init_pcap(addr);
@ -286,7 +286,7 @@ unsigned int wpcap_read(unsigned char *buf, unsigned int buflen)
switch (pcap_next_ex(pcap, &packet_header, &packet)) switch (pcap_next_ex(pcap, &packet_header, &packet))
{ {
case -1: case -1:
error_exit("error on read\n"); error_exit("error on read");
case 0: case 0:
return 0; return 0;
} }
@ -304,6 +304,6 @@ void wpcap_send(unsigned char *buf, unsigned int buflen)
{ {
if (pcap_sendpacket(pcap, buf, buflen) == -1) if (pcap_sendpacket(pcap, buf, buflen) == -1)
{ {
error_exit("error on send\n"); error_exit("error on send");
} }
} }

View File

@ -96,7 +96,7 @@ static inline int up_x11createframe(void)
g_display = XOpenDisplay(NULL); g_display = XOpenDisplay(NULL);
if (g_display == NULL) if (g_display == NULL)
{ {
printf("Unable to open display.\n"); printf("Unable to open display.\r\n");
return -1; return -1;
} }
@ -228,7 +228,6 @@ static void up_x11uninitX(void)
#ifndef CONFIG_SIM_X11NOSHM #ifndef CONFIG_SIM_X11NOSHM
static void up_x11uninitialize(void) static void up_x11uninitialize(void)
{ {
fprintf(stderr, "Uninitializing\n");
if (g_shmcheckpoint > 1) if (g_shmcheckpoint > 1)
{ {
if (!b_useshm && g_framebuffer) if (!b_useshm && g_framebuffer)
@ -263,7 +262,6 @@ static inline int up_x11mapsharedmem(int depth, unsigned int fblen)
if (XShmQueryExtension(g_display)) if (XShmQueryExtension(g_display))
{ {
b_useshm = 1; b_useshm = 1;
printf("Using shared memory.\n");
up_x11traperrors(); up_x11traperrors();
g_image = XShmCreateImage(g_display, g_image = XShmCreateImage(g_display,
@ -278,7 +276,7 @@ static inline int up_x11mapsharedmem(int depth, unsigned int fblen)
if (!g_image) if (!g_image)
{ {
fprintf(stderr, "Unable to create g_image."); fprintf(stderr, "Unable to create g_image.\r\n");
return -1; return -1;
} }
@ -336,7 +334,7 @@ shmerror:
if (g_image == NULL) if (g_image == NULL)
{ {
fprintf(stderr, "Unable to create g_image\n"); fprintf(stderr, "Unable to create g_image\r\n");
return -1; return -1;
} }
@ -417,8 +415,6 @@ int up_x11cmap(unsigned short first, unsigned short len,
Colormap cMap; Colormap cMap;
int ndx; int ndx;
printf("Creating Colormap\n");
/* Convert each color to X11 scaling */ /* Convert each color to X11 scaling */
cMap = DefaultColormap(g_display, g_screen); cMap = DefaultColormap(g_display, g_screen);
@ -439,7 +435,7 @@ int up_x11cmap(unsigned short first, unsigned short len,
if (!XAllocColor(g_display, cMap, &color)) if (!XAllocColor(g_display, cMap, &color))
{ {
fprintf(stderr, "Failed to allocate color%d\n", ndx); fprintf(stderr, "Failed to allocate color%d\r\n", ndx);
return -1; return -1;
} }
} }