Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pcercuei committed Apr 7, 2022
2 parents f753364 + b1099c9 commit e791f32
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 14 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ set_target_properties(iio ${IIO_COMPAT_LIB} PROPERTIES
)
if (WIN32)
if (MSVC)
target_link_options(iio PUBLIC /DEBUG)
set(LIBIIO_WIN32_PREFIX lib)
endif()

Expand Down Expand Up @@ -131,7 +132,9 @@ set(LEVEL_Debug 5)
set(DEFAULT_LOG_LEVEL ${LEVEL_${LOG_LEVEL}})

if (MSVC)
target_compile_options(iio PRIVATE /W4 /wd4200 /wd4127 /wd4100)
target_compile_options(iio PRIVATE /Zi /W4 /wd4200 /wd4127 /wd4100)
# Zi produces a separate PDB file that contains all the symbolic debugging information
# W4 displays level 1, 2, 3, and 4 (informational) warnings that aren't off by default
# C4200: nonstandard extension used : zero-sized array in struct (usb.h)
# C4127: conditional expression is constant (IIO_ERROR and IIO_DEBUG macros)
# C4100: unreferenced parameter; same as -Wno-unused-parameter
Expand Down
2 changes: 1 addition & 1 deletion dns_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static int dnssd_add_scan_result(const struct iio_context_params *params,
char *hostname, char *addr_str, uint16_t port)
{
struct iio_context *ctx;
char uri[sizeof("ip:") + MAXHOSTNAMELEN + sizeof (":65535") + 1];
char uri[sizeof("ip:") + FQDN_LEN + sizeof (":65535") + 1];
char description[255], *p;
const char *hw_model, *serial;
unsigned int i;
Expand Down
4 changes: 1 addition & 3 deletions dns_sd.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@

#ifdef _WIN32
#include <winsock2.h>
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN (MAX_COMPUTERNAME_LENGTH+1)
#endif /* MAXHOSTNAMELEN */
#else
#include <sys/param.h>
#endif

#define DNS_SD_ADDRESS_STR_MAX (40) /* IPv6 Max = 4*8 + 7 + 1 for NUL */
#define FQDN_LEN (255) /* RFC 1035 */

/* MacOS doesn't include ENOMEDIUM (No medium found) like Linux does */
#ifndef ENOMEDIUM
Expand Down
4 changes: 2 additions & 2 deletions dns_sd_bonjour.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ static void __cfnet_browser_cb(CFNetServiceBrowserRef browser,
const struct iio_context_params *params = bdata->params;
char address_v4[DNS_SD_ADDRESS_STR_MAX+1] = "";
char address_v6[DNS_SD_ADDRESS_STR_MAX+1] = "";
char hostname[MAXHOSTNAMELEN];
char name[MAXHOSTNAMELEN];
char hostname[FQDN_LEN];
char name[FQDN_LEN];
bool have_v4 = false;
bool have_v6 = false;
struct sockaddr_in *sa;
Expand Down
3 changes: 0 additions & 3 deletions network-windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
#include <errno.h>
#include <ws2tcpip.h>
#define close(s) closesocket(s)
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN (MAX_COMPUTERNAME_LENGTH+1)
#endif /* MAXHOSTNAMELEN */

int set_blocking_mode(int s, bool blocking)
{
Expand Down
2 changes: 1 addition & 1 deletion network.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ static struct iio_context * network_create_context(const struct iio_context_para
char *description, *end, *port = NULL;
const char *ctx_attrs[] = { "ip,ip-addr", "uri" };
const char *ctx_values[2];
char uri[MAXHOSTNAMELEN + 3];
char uri[FQDN_LEN + 3];
char port_str[6];
uint16_t port_num = IIOD_PORT;

Expand Down
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if (MSVC)
target_sources(iio_tests_helper PRIVATE ../deps/wingetopt/src/getopt.c)
target_include_directories(iio_tests_helper PUBLIC ../deps/wingetopt/src)
target_compile_definitions(iio_tests_helper PRIVATE _CRT_SECURE_NO_WARNINGS)
target_link_options(iio_tests_helper PUBLIC /DEBUG)
endif()
set_target_properties(iio_tests_helper PROPERTIES
C_STANDARD 99
Expand All @@ -42,6 +43,9 @@ foreach (test ${IIO_TESTS_TARGETS})
target_compile_definitions(${test} PRIVATE IIO_CHECK_RET)
endif()
target_link_libraries(${test} LINK_PRIVATE iio iio_tests_helper)
if (MSVC)
target_link_options(${test} PUBLIC /DEBUG)
endif()
endforeach()

if(PTHREAD_LIBRARIES)
Expand Down
2 changes: 1 addition & 1 deletion tests/iio_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ uint64_t get_time_us(void)
{
struct timespec tp;

#ifdef _WIN32
#ifdef _MSC_BUILD
timespec_get(&tp, TIME_UTC);
#else
clock_gettime(CLOCK_REALTIME, &tp);
Expand Down
4 changes: 2 additions & 2 deletions utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ char *iio_strndup(const char *str, size_t n)
#ifdef HAS_STRNDUP
return strndup(str, n);
#else
size_t len = strnlen(str, n + 1);
size_t len = strnlen(str, n);
char *buf = malloc(len + 1);
if (buf) {
/* len = size of buf, so memcpy is OK */
Expand Down Expand Up @@ -310,7 +310,7 @@ char * iio_getenv (char * envvar)
if (!hostname)
return NULL;

tmp = MAXHOSTNAMELEN + sizeof("serial:") + sizeof(":65535") - 2;
tmp = FQDN_LEN + sizeof("serial:") + sizeof(":65535") - 2;
len = strnlen(hostname, tmp);

/* Should be smaller than max length */
Expand Down

0 comments on commit e791f32

Please sign in to comment.