mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 01:42:58 +08:00
arch/sim: replace printf fprintf to syslog, '\r\n' -> '\n'
should use syslog in kernel RP check failed because host code call host API has style AaaBbb, so, ignore the RP check Change-Id: Iad3468dae2cd07e6dd92874c5e6d38d9018bee6c Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
@@ -40,10 +40,12 @@
|
||||
#ifdef VFAT_STANDALONE
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <syslog.h>
|
||||
# include <zlib.h>
|
||||
#else
|
||||
# include <nuttx/config.h>
|
||||
|
||||
# include <syslog.h>
|
||||
# include <stdlib.h>
|
||||
# include <debug.h>
|
||||
# include <zlib.h>
|
||||
@@ -58,7 +60,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef VFAT_STANDALONE
|
||||
# define serr(format, ...) printf(format, ##__VA_ARGS__)
|
||||
# define serr(format, ...) syslog(LOG_ERR, format, ##__VA_ARGS__)
|
||||
# define kmm_malloc(size) malloc(size)
|
||||
# define kmm_free(mem) free(mem)
|
||||
#endif
|
||||
@@ -410,12 +412,12 @@ int main(int argc, char **argv, char **envp)
|
||||
int check;
|
||||
|
||||
cmf = g_vfatdata[0];
|
||||
printf("CMF=%02x: CM=%d CINFO=%d\n", cmf, cmf & 0x0f, cmf >> 4);
|
||||
syslog(LOG_INFO, "CMF=%02x: CM=%d CINFO=%d\n", cmf, cmf & 0x0f, cmf >> 4);
|
||||
|
||||
flg = g_vfatdata[1];
|
||||
fdict = (flg >> 5) & 1;
|
||||
|
||||
printf("FLG=%02x: FCHECK=%d FDICT=%d FLEVEL=%d\n",
|
||||
syslog(LOG_INFO, "FLG=%02x: FCHECK=%d FDICT=%d FLEVEL=%d\n",
|
||||
flg, flg & 0x1f, fdict, flg >> 6);
|
||||
|
||||
/* The FCHECK value must be such that CMF and FLG, when viewed as
|
||||
@@ -426,19 +428,19 @@ int main(int argc, char **argv, char **envp)
|
||||
check = cmf * 256 + flg;
|
||||
if (check % 31 != 0)
|
||||
{
|
||||
printf("Fails check: %04x is not a multiple of 31\n", check);
|
||||
syslog(LOG_INFO, "Fails check: %04x is not a multiple of 31\n", check);
|
||||
}
|
||||
|
||||
deviceimage = up_deviceimage();
|
||||
if (deviceimage)
|
||||
{
|
||||
printf("Inflate SUCCEEDED\n");
|
||||
syslog(LOG_INFO, "Inflate SUCCEEDED\n");
|
||||
kmm_free(deviceimage);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Inflate FAILED\n");
|
||||
syslog(LOG_INFO, "Inflate FAILED\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <syslog.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/init.h>
|
||||
@@ -112,10 +113,10 @@ void up_assert(const char *filename, int line)
|
||||
/* Show the location of the failed assertion */
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
fprintf(stderr, "CPU%d: Assertion failed at file:%s line: %d\r\n",
|
||||
syslog(LOG_ERR, "CPU%d: Assertion failed at file:%s line: %d\n",
|
||||
up_cpu_index(), filename, line);
|
||||
#else
|
||||
fprintf(stderr, "Assertion failed at file:%s line: %d\r\n",
|
||||
syslog(LOG_ERR, "Assertion failed at file:%s line: %d\n",
|
||||
filename, line);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef CONFIG_SIM_NET_HOST_ROUTE
|
||||
@@ -111,9 +112,9 @@ static struct rtentry ghostroute;
|
||||
static inline void dump_ethhdr(const char *msg, unsigned char *buf,
|
||||
int buflen)
|
||||
{
|
||||
printf("TAPDEV: %s %d bytes\r\n", msg, buflen);
|
||||
printf(" %02x:%02x:%02x:%02x:%02x:%02x "
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x %02x%02x\r\n",
|
||||
syslog(LOG_INFO, "TAPDEV: %s %d bytes\n", msg, buflen);
|
||||
syslog(LOG_INFO, " %02x:%02x:%02x:%02x:%02x:%02x "
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x %02x%02x\n",
|
||||
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
|
||||
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
|
||||
#ifdef CONFIG_ENDIAN_BIG
|
||||
@@ -175,7 +176,7 @@ void tapdev_init(void)
|
||||
tapdevfd = open(DEVTAP, O_RDWR, 0644);
|
||||
if (tapdevfd < 0)
|
||||
{
|
||||
printf("TAPDEV: open failed: %d\r\n", -tapdevfd);
|
||||
syslog(LOG_ERR, "TAPDEV: open failed: %d\n", -tapdevfd);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,7 +187,7 @@ void tapdev_init(void)
|
||||
ret = ioctl(tapdevfd, TUNSETIFF, (unsigned long) &ifr);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("TAPDEV: ioctl failed: %d\r\n", -ret);
|
||||
syslog(LOG_ERR, "TAPDEV: ioctl failed: %d\n", -ret);
|
||||
close(tapdevfd);
|
||||
return;
|
||||
}
|
||||
@@ -203,7 +204,7 @@ void tapdev_init(void)
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
printf("TAPDEV: Can't open socket: %d\r\n", -sockfd);
|
||||
syslog(LOG_ERR, "TAPDEV: Can't open socket: %d\n", -sockfd);
|
||||
close(tapdevfd);
|
||||
return;
|
||||
}
|
||||
@@ -217,8 +218,8 @@ void tapdev_init(void)
|
||||
ret = ioctl(sockfd, SIOCBRADDIF, &ifr);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("TAPDEV: ioctl failed (can't add interface %s to "
|
||||
"bridge %s): %d\r\n",
|
||||
syslog(LOG_ERR, "TAPDEV: ioctl failed (can't add interface %s to "
|
||||
"bridge %s): %d\n",
|
||||
gdevname, CONFIG_SIM_NET_BRIDGE_DEVICE, -ret);
|
||||
close(sockfd);
|
||||
close(tapdevfd);
|
||||
@@ -229,8 +230,8 @@ void tapdev_init(void)
|
||||
close(sockfd);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("TAPDEV: ioctl failed (can't get MTU "
|
||||
"from %s): %d\r\n", gdevname, -ret);
|
||||
syslog(LOG_ERR, "TAPDEV: ioctl failed (can't get MTU "
|
||||
"from %s): %d\n", gdevname, -ret);
|
||||
close(tapdevfd);
|
||||
return;
|
||||
}
|
||||
@@ -282,7 +283,7 @@ unsigned int tapdev_read(unsigned char *buf, unsigned int buflen)
|
||||
ret = read(gtapdevfd, buf, buflen);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("TAPDEV: read failed: %d\r\n", -ret);
|
||||
syslog(LOG_ERR, "TAPDEV: read failed: %d\n", -ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -300,12 +301,12 @@ void tapdev_send(unsigned char *buf, unsigned int buflen)
|
||||
}
|
||||
|
||||
#ifdef TAPDEV_DEBUG
|
||||
printf("tapdev_send: sending %d bytes\r\n", buflen);
|
||||
syslog(LOG_INFO, "tapdev_send: sending %d bytes\n", buflen);
|
||||
|
||||
gdrop++;
|
||||
if (gdrop % 8 == 7)
|
||||
{
|
||||
printf("TAPDEV: Dropped a packet!\r\n");
|
||||
syslog(LOG_ERR, "TAPDEV: Dropped a packet!\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -313,7 +314,7 @@ void tapdev_send(unsigned char *buf, unsigned int buflen)
|
||||
ret = write(gtapdevfd, buf, buflen);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("TAPDEV: write failed: %d\r\n", -ret);
|
||||
syslog(LOG_ERR, "TAPDEV: write failed: %d\n", -ret);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -340,7 +341,7 @@ void tapdev_ifup(in_addr_t ifaddr)
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
printf("TAPDEV: Can't open socket: %d\r\n", -sockfd);
|
||||
syslog(LOG_ERR, "TAPDEV: Can't open socket: %d\n", -sockfd);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -351,8 +352,8 @@ void tapdev_ifup(in_addr_t ifaddr)
|
||||
ret = ioctl(sockfd, SIOCGIFFLAGS, (unsigned long)&ifr);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("TAPDEV: ioctl failed "
|
||||
"(can't get interface flags): %d\r\n", -ret);
|
||||
syslog(LOG_ERR, "TAPDEV: ioctl failed "
|
||||
"(can't get interface flags): %d\n", -ret);
|
||||
close(sockfd);
|
||||
return;
|
||||
}
|
||||
@@ -361,8 +362,8 @@ void tapdev_ifup(in_addr_t ifaddr)
|
||||
ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&ifr);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("TAPDEV: ioctl failed "
|
||||
"(can't set interface flags): %d\r\n", -ret);
|
||||
syslog(LOG_ERR, "TAPDEV: ioctl failed "
|
||||
"(can't set interface flags): %d\n", -ret);
|
||||
close(sockfd);
|
||||
return;
|
||||
}
|
||||
@@ -383,7 +384,8 @@ void tapdev_ifup(in_addr_t ifaddr)
|
||||
ret = ioctl(sockfd, SIOCADDRT, (unsigned long)&ghostroute);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("TAPDEV: ioctl failed (can't add host route): %d\r\n", -ret);
|
||||
syslog(LOG_ERR, "TAPDEV: ioctl failed
|
||||
(can't add host route): %d\n", -ret);
|
||||
close(sockfd);
|
||||
return;
|
||||
}
|
||||
@@ -410,15 +412,15 @@ void tapdev_ifdown(void)
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
printf("TAPDEV: Can't open socket: %d\r\n", -sockfd);
|
||||
syslog(LOG_ERR, "TAPDEV: Can't open socket: %d\n", -sockfd);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = ioctl(sockfd, SIOCDELRT, (unsigned long)&ghostroute);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("TAPDEV: ioctl failed "
|
||||
"(can't delete host route): %d\r\n", -ret);
|
||||
syslog(LOG_ERR, "TAPDEV: ioctl failed "
|
||||
"(can't delete host route): %d\n", -ret);
|
||||
}
|
||||
|
||||
close(sockfd);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "up_internal.h"
|
||||
@@ -43,9 +44,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#define ERROR(fmt, ...) \
|
||||
fprintf(stderr, "up_vpnkit: " fmt "\r\n", ##__VA_ARGS__)
|
||||
syslog(LOG_ERR, "up_vpnkit: " fmt "\n", ##__VA_ARGS__)
|
||||
#define INFO(fmt, ...) \
|
||||
fprintf(stderr, "up_vpnkit: " fmt "\r\n", ##__VA_ARGS__)
|
||||
syslog(LOG_ERR, "up_vpnkit: " fmt "\n", ##__VA_ARGS__)
|
||||
#define DEBUG(fmt, ...)
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@@ -123,7 +124,7 @@ static pcap_sendpacket_t pcap_sendpacket;
|
||||
|
||||
static void error_exit(char *message)
|
||||
{
|
||||
printf("error_exit: %s\r\n", message);
|
||||
syslog(LOG_INFO, "error_exit: %s\n", message);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -139,7 +140,8 @@ static void init_pcap(struct in_addr addr)
|
||||
|
||||
while (interfaces != NULL)
|
||||
{
|
||||
printf("init_pcap: found interface: %s\r\n", interfaces->description);
|
||||
syslog(LOG_INFO, "init_pcap: found interface: %s\n",
|
||||
interfaces->description);
|
||||
|
||||
if (interfaces->addresses != NULL &&
|
||||
interfaces->addresses->addr != NULL &&
|
||||
@@ -148,7 +150,7 @@ static void init_pcap(struct in_addr addr)
|
||||
struct in_addr interface_addr;
|
||||
interface_addr =
|
||||
((struct sockaddr_in *)interfaces->addresses->addr)->sin_addr;
|
||||
printf("init_pcap: with address: %s\r\n",
|
||||
syslog(LOG_INFO, ("init_pcap: with address: %s\n",
|
||||
inet_ntoa(interface_addr));
|
||||
|
||||
if (interface_addr.s_addr == addr.s_addr)
|
||||
@@ -200,7 +202,7 @@ static void set_ethaddr(struct in_addr addr)
|
||||
char buffer[256];
|
||||
WideCharToMultiByte(CP_ACP, 0, adapters->Description, -1,
|
||||
buffer, sizeof(buffer), NULL, NULL);
|
||||
printf("set_ethaddr: found adapter: %s\r\n", buffer);
|
||||
syslog(LOG_INFO, "set_ethaddr: found adapter: %s\n", buffer);
|
||||
|
||||
if (adapters->FirstUnicastAddress != NULL &&
|
||||
adapters->FirstUnicastAddress->Address.lpSockaddr != NULL &&
|
||||
@@ -211,7 +213,7 @@ static void set_ethaddr(struct in_addr addr)
|
||||
adapter_addr =
|
||||
((struct sockaddr_in *)adapters->FirstUnicastAddress->Address.
|
||||
lpSockaddr)->sin_addr;
|
||||
printf("set_ethaddr: with address: %s\r\n",
|
||||
syslog(LOG_INFO, "set_ethaddr: with address: %s\n",
|
||||
inet_ntoa(adapter_addr));
|
||||
|
||||
if (adapter_addr.s_addr == addr.s_addr)
|
||||
@@ -221,7 +223,7 @@ static void set_ethaddr(struct in_addr addr)
|
||||
error_exit("ip addr does not belong to an ethernet card");
|
||||
}
|
||||
|
||||
printf("set_ethaddr: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
||||
syslog(LOG_INFO, "set_ethaddr:%02X-%02X-%02X-%02X-%02X-%02X\n",
|
||||
adapters->PhysicalAddress[0], adapters->PhysicalAddress[1],
|
||||
adapters->PhysicalAddress[2], adapters->PhysicalAddress[3],
|
||||
adapters->PhysicalAddress[4], adapters->PhysicalAddress[5]);
|
||||
@@ -250,7 +252,7 @@ void wpcap_init(void)
|
||||
FARPROC dlladdr;
|
||||
|
||||
addr.s_addr = htonl(WCAP_IPADDR);
|
||||
printf("wpcap_init: IP address: %s\r\n", inet_ntoa(addr));
|
||||
syslog(LOG_INFO, "wpcap_init: IP address: %s\n", inet_ntoa(addr));
|
||||
|
||||
wpcap = LoadLibrary("wpcap.dll");
|
||||
dlladdr = GetProcAddress(wpcap, "pcap_findalldevs");
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <sys/ipc.h>
|
||||
@@ -86,7 +87,11 @@ static int b_useshm;
|
||||
static inline int up_x11createframe(void)
|
||||
{
|
||||
XGCValues gcval;
|
||||
char *argv[2] = { "nuttx", NULL };
|
||||
char *argv[2] =
|
||||
{
|
||||
"nuttx", NULL
|
||||
};
|
||||
|
||||
char *winName = "NuttX";
|
||||
char *iconName = "NX";
|
||||
XTextProperty winprop;
|
||||
@@ -96,7 +101,7 @@ static inline int up_x11createframe(void)
|
||||
g_display = XOpenDisplay(NULL);
|
||||
if (g_display == NULL)
|
||||
{
|
||||
printf("Unable to open display.\r\n");
|
||||
syslog(LOG_ERR, "Unable to open display.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -276,7 +281,7 @@ static inline int up_x11mapsharedmem(int depth, unsigned int fblen)
|
||||
|
||||
if (!g_image)
|
||||
{
|
||||
fprintf(stderr, "Unable to create g_image.\r\n");
|
||||
syslog(LOG_ERR, "Unable to create g_image.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -334,7 +339,7 @@ shmerror:
|
||||
|
||||
if (g_image == NULL)
|
||||
{
|
||||
fprintf(stderr, "Unable to create g_image\r\n");
|
||||
syslog(LOG_ERR, "Unable to create g_image\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -435,7 +440,7 @@ int up_x11cmap(unsigned short first, unsigned short len,
|
||||
|
||||
if (!XAllocColor(g_display, cMap, &color))
|
||||
{
|
||||
fprintf(stderr, "Failed to allocate color%d\r\n", ndx);
|
||||
syslog(LOG_ERR, "Failed to allocate color%d\n", ndx);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "protocol.h"
|
||||
|
||||
@@ -51,9 +52,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#define ERROR(fmt, ...) \
|
||||
fprintf(stderr, "up_vpnkit: " fmt "\r\n", ##__VA_ARGS__)
|
||||
syslog(LOG_ERR, "up_vpnkit: " fmt "\n", ##__VA_ARGS__)
|
||||
#define INFO(fmt, ...) \
|
||||
fprintf(stderr, "up_vpnkit: " fmt "\r\n", ##__VA_ARGS__)
|
||||
syslog(LOG_ERR, "up_vpnkit: " fmt "\n", ##__VA_ARGS__)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "protocol.h"
|
||||
|
||||
@@ -55,7 +56,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#define ERROR(fmt, ...) \
|
||||
fprintf(stderr, "up_vpnkit: " fmt "\r\n", ##__VA_ARGS__)
|
||||
syslog(LOG_ERR, "up_vpnkit: " fmt "\n", ##__VA_ARGS__)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
|
||||
Reference in New Issue
Block a user