mirror of
https://github.com/RPCS3/hidapi.git
synced 2026-01-31 01:25:21 +01:00
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.
This commit is contained in:
@@ -63,18 +63,13 @@ extern "C" {
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "hidapi.h"
|
||||
|
||||
#undef MIN
|
||||
#define MIN(x,y) ((x) < (y)? (x): (y))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* Thanks Microsoft, but I know how to use strncpy(). */
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -330,8 +325,7 @@ static struct hid_device_info *hid_get_device_info(const char *path, HANDLE hand
|
||||
if (path) {
|
||||
size_t len = strlen(path);
|
||||
dev->path = (char*)calloc(len + 1, sizeof(char));
|
||||
strncpy(dev->path, path, len + 1);
|
||||
dev->path[len] = '\0';
|
||||
memcpy(dev->path, path, len + 1);
|
||||
}
|
||||
else
|
||||
dev->path = NULL;
|
||||
|
||||
Reference in New Issue
Block a user