From: manish.r Date: Fri, 27 Dec 2019 06:55:44 +0000 (+0530) Subject: gcc9 build fix X-Git-Tag: submit/tizen/20191230.070409^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=866af69aeb1f2350f9514f6624716ffb2825696f;p=sdk%2Ftarget%2Fsdbd.git gcc9 build fix Change-Id: I720c6984327f1a38a102973487a7d746ff56b333 Signed-off-by: manish.r --- diff --git a/src/descs_strings.h b/src/descs_strings.h index d36b33a..033293b 100644 --- a/src/descs_strings.h +++ b/src/descs_strings.h @@ -7,8 +7,21 @@ #define MAX_PACKET_SIZE_FS 64 #define MAX_PACKET_SIZE_HS 512 -#define cpu_to_le16(x) htole16(x) -#define cpu_to_le32(x) htole32(x) +/* + * cpu_to_le16/32 are used when initializing structures, a context where a + * function call is not allowed. To solve this, we code cpu_to_le16/32 in a way + * that allows them to be used when initializing structures. + */ + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define cpu_to_le16(x) (x) +#define cpu_to_le32(x) (x) +#else +#define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)) +#define cpu_to_le32(x) \ + ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \ + (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24)) +#endif extern struct sdb_usb_descs { struct usb_functionfs_descs_head header; diff --git a/src/sdb.c b/src/sdb.c index b35ebae..d16a437 100644 --- a/src/sdb.c +++ b/src/sdb.c @@ -1208,7 +1208,7 @@ static void sdb_cleanup(void) void start_device_log(void) { int fd; - char path[PATH_MAX] = {0, }; + char path[2*PATH_MAX] = {0, }; char path_folder[PATH_MAX] = {0, }; char path_file[PATH_MAX] = {0, }; struct tm now; diff --git a/src/transport_local.c b/src/transport_local.c index eab7712..7601969 100644 --- a/src/transport_local.c +++ b/src/transport_local.c @@ -442,7 +442,7 @@ static int send_msg_to_localhost_from_guest(const char *host_ip, int local_port, // send the "emulator" request to sdbserver static void* notify_sdbd_startup_thread(void* ptr) { char buffer[512]; - char request[512]; + char request[500]; SdbdCommandlineArgs *sdbd_args = &sdbd_commandline_args; // alias