Skip to content

Commit 8741697

Browse files
authored
Update hid.c to fix MSYS2 MinGW-w64 compiler warning (#311)
This fixed a compiler warning when using MSYS2 MinGW-w64 compiler as mentioned in issue #289. Since we changed strncpy to memcpy, it is not necessary to disable warning 4996 for MSVC.
1 parent ac8c9e5 commit 8741697

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

windows/hid.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,13 @@ extern "C" {
6363

6464
#include <stdio.h>
6565
#include <stdlib.h>
66-
66+
#include <string.h>
6767

6868
#include "hidapi.h"
6969

7070
#undef MIN
7171
#define MIN(x,y) ((x) < (y)? (x): (y))
7272

73-
#ifdef _MSC_VER
74-
/* Thanks Microsoft, but I know how to use strncpy(). */
75-
#pragma warning(disable:4996)
76-
#endif
77-
7873
#ifdef __cplusplus
7974
extern "C" {
8075
#endif
@@ -330,8 +325,7 @@ static struct hid_device_info *hid_get_device_info(const char *path, HANDLE hand
330325
if (path) {
331326
size_t len = strlen(path);
332327
dev->path = (char*)calloc(len + 1, sizeof(char));
333-
strncpy(dev->path, path, len + 1);
334-
dev->path[len] = '\0';
328+
memcpy(dev->path, path, len + 1);
335329
}
336330
else
337331
dev->path = NULL;

0 commit comments

Comments
 (0)