Skip to content

Fix warnings in unit test BSP #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/fake_bsp/fakegoodbsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef enum {
}
#define RESULT_STR(X) \
do { \
size_t Xlen = strnlen(X, MAX_NAME_SIZE) + 1; \
size_t Xlen = strlen(X) + 1; \
memcpy((void *)param_value, X, \
(param_value_size <= Xlen) ? param_value_size : Xlen); \
if (param_size_ret) \
Expand Down Expand Up @@ -282,14 +282,14 @@ AOCL_MMD_CALL int aocl_mmd_read(int handle, aocl_mmd_op_t op, size_t len,
fprintf(stderr, "Error: Not handling read of 0x%x in unit test\n",
(unsigned int)offset);
return -1;
case OFFSET_CONFIGURATION_ROM:
if (strnlen(config_str, MAX_NAME_SIZE) <= len) {
memcpy(dst, (void *)config_str, len);
return 0;
} else {
case OFFSET_CONFIGURATION_ROM: {
const size_t config_len = strlen(config_str);
if (!(config_len < len)) {
return -1;
}
break;
memcpy(dst, config_str, config_len + 1);
return 0;
}
case OFFSET_COUNTER:
if (len == sizeof(unsigned int)) {
memcpy(dst, &offset_counter, len);
Expand Down
14 changes: 7 additions & 7 deletions test/fake_bsp/missingfuncbsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef enum {
}
#define RESULT_STR(X) \
do { \
size_t Xlen = strnlen(X, MAX_NAME_SIZE) + 1; \
size_t Xlen = strlen(X) + 1; \
memcpy((void *)param_value, X, \
(param_value_size <= Xlen) ? param_value_size : Xlen); \
if (param_size_ret) \
Expand Down Expand Up @@ -267,14 +267,14 @@ AOCL_MMD_CALL int aocl_mmd_read(int handle, aocl_mmd_op_t op, size_t len,
fprintf(stderr, "Error: Not handling read of 0x%x in unit test\n",
(unsigned int)offset);
return -1;
case OFFSET_CONFIGURATION_ROM:
if (strnlen(config_str, MAX_NAME_SIZE) <= len) {
memcpy(dst, (void *)config_str, len);
return 0;
} else {
case OFFSET_CONFIGURATION_ROM: {
const size_t config_len = strlen(config_str);
if (!(config_len < len)) {
return -1;
}
break;
memcpy(dst, config_str, config_len + 1);
return 0;
}
case OFFSET_COUNTER:
fprintf(stderr, "Error: Not handling read of 0x%x in unit test\n",
(unsigned int)offset);
Expand Down