Skip to content

Commit

Permalink
fix: remove strncpy output truncated before terminating nul errors
Browse files Browse the repository at this point in the history
# [footer]

# //////////////////////////////////////////////////////////////////////////////
# [title.type]
#  Must be one of the following:
#  - fix: Commits that fix bugs
#  - feat: Commits that add new features
#  - refactor: Commits that change existing code without changing any behavior
#  - perf: Special refactor commits that improve performance
#  - style: Commits that do not affect meaning (white-space, formatting, etc.)
#  - test: Commits that add tests or fixing existing tests
#  - docs: Commits that affect documentation only
#  - build: Commits that change build components (scripts, CI pipeline, etc.)
#  - chore: Miscellaneous commits (modifying .gitignore, etc.)
#  - tag: Commits for adding tags
#
# [title.scope]
#  The scope should be the name of the npm package affected. The following is
#  the list of supported scopes:
#  - xa: XAgent (default)
#  - usi: Unified Storage Interface
#  - uls: Unified Log System
#
# [title.summary]
#  Use the summary field to provide a succinct description of the change:
#  - Use the imperative, present tense: "change" not "changed" nor "changes"
#  - Don't capitalize the first letter
#  - No period (.) at the end
#
# [body]
#  Just as in the summary, use the imperative, present tense: "fix" not "fixed"
#  nor "fixes".
#
#  Explain the motivation for the change in the commit message body. This commit
#  message should explain why you are making the change. You can include a
#  comparison of the previous behavior with the new behavior in order to
#  illustrate the impact of the change.
#
# [footer]
#  The footer can contain information about breaking changes and deprecations
#  and is also the place to reference GitHub issues, JIRA tickets, and other PRs
#  that this commit closes or is related to. For example:
#
#  Resolves XCAGENT-100
#  Resolves XCAGENT-100, SEAL-1500, XCAGENT-512
#
#  BREAKING CHANGE: <breaking change summary>
#  <BLANK LINE>
#  <breaking change description + migration instructions>
#  <BLANK LINE>
#  <BLANK LINE>
#  Resolves <JIRA ticket>
#
#  DEPRECATED: <what is deprecated>
#  <BLANK LINE>
#  <deprecation description + recommended update path>
#  <BLANK LINE>
#  <BLANK LINE>
#  Resolves #<JIRA ticket>
  • Loading branch information
tomghuang committed Jul 20, 2024
1 parent 8637658 commit 76fd157
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions tests/testarghashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ void test_arghashtable_basic_002(CuTest* tc) {
char* key_1 = "k1";
char* k_1 = (char*)malloc(strlen(key_1) + 1);
memset(k_1, 0, strlen(key_1) + 1);
strncpy(k_1, key_1, strlen(key_1));
memcpy(k_1, key_1, strlen(key_1));

char* value_1 = "v1";
char* v_1 = (char*)malloc(strlen(value_1) + 1);
memset(v_1, 0, strlen(value_1) + 1);
strncpy(v_1, value_1, strlen(value_1));
memcpy(v_1, value_1, strlen(value_1));

arg_hashtable_insert(h, k_1, v_1);
CuAssertIntEquals(tc, 1, arg_hashtable_count(h));
Expand All @@ -104,25 +104,25 @@ void test_arghashtable_basic_003(CuTest* tc) {
char* key_1 = "k1";
char* k_1 = (char*)malloc(strlen(key_1) + 1);
memset(k_1, 0, strlen(key_1) + 1);
strncpy(k_1, key_1, strlen(key_1));
memcpy(k_1, key_1, strlen(key_1));

char* value_1 = "v1";
char* v_1 = (char*)malloc(strlen(value_1) + 1);
memset(v_1, 0, strlen(value_1) + 1);
strncpy(v_1, value_1, strlen(value_1));
memcpy(v_1, value_1, strlen(value_1));

arg_hashtable_insert(h, k_1, v_1);
CuAssertIntEquals(tc, 1, arg_hashtable_count(h));

char* key_2 = "k2";
char* k_2 = (char*)malloc(strlen(key_2) + 1);
memset(k_2, 0, strlen(key_2) + 1);
strncpy(k_2, key_2, strlen(key_2));
memcpy(k_2, key_2, strlen(key_2));

char* value_2 = "v2";
char* v_2 = (char*)malloc(strlen(value_2) + 1);
memset(v_2, 0, strlen(value_2) + 1);
strncpy(v_2, value_2, strlen(value_2));
memcpy(v_2, value_2, strlen(value_2));

arg_hashtable_insert(h, k_2, v_2);
CuAssertIntEquals(tc, 2, arg_hashtable_count(h));
Expand All @@ -148,12 +148,12 @@ void test_arghashtable_basic_004(CuTest* tc) {
char* key_1 = "k1";
char* k_1 = (char*)malloc(strlen(key_1) + 1);
memset(k_1, 0, strlen(key_1) + 1);
strncpy(k_1, key_1, strlen(key_1));
memcpy(k_1, key_1, strlen(key_1));

char* value_1 = "v1";
char* v_1 = (char*)malloc(strlen(value_1) + 1);
memset(v_1, 0, strlen(value_1) + 1);
strncpy(v_1, value_1, strlen(value_1));
memcpy(v_1, value_1, strlen(value_1));

arg_hashtable_insert(h, k_1, v_1);
CuAssertTrue(tc, h != 0);
Expand All @@ -176,12 +176,12 @@ void test_arghashtable_basic_005(CuTest* tc) {
char* key_1 = "k1";
char* k_1 = (char*)malloc(strlen(key_1) + 1);
memset(k_1, 0, strlen(key_1) + 1);
strncpy(k_1, key_1, strlen(key_1));
memcpy(k_1, key_1, strlen(key_1));

char* value_1 = "v1";
char* v_1 = (char*)malloc(strlen(value_1) + 1);
memset(v_1, 0, strlen(value_1) + 1);
strncpy(v_1, value_1, strlen(value_1));
memcpy(v_1, value_1, strlen(value_1));

arg_hashtable_insert(h, k_1, v_1);
CuAssertTrue(tc, h != 0);
Expand All @@ -201,12 +201,12 @@ void test_arghashtable_basic_006(CuTest* tc) {
char* key_1 = "k1";
char* k_1 = (char*)malloc(strlen(key_1) + 1);
memset(k_1, 0, strlen(key_1) + 1);
strncpy(k_1, key_1, strlen(key_1));
memcpy(k_1, key_1, strlen(key_1));

char* value_1 = "v1";
char* v_1 = (char*)malloc(strlen(value_1) + 1);
memset(v_1, 0, strlen(value_1) + 1);
strncpy(v_1, value_1, strlen(value_1));
memcpy(v_1, value_1, strlen(value_1));

arg_hashtable_insert(h, k_1, v_1);
CuAssertTrue(tc, arg_hashtable_count(h) == 1);
Expand All @@ -225,25 +225,25 @@ void test_arghashtable_basic_007(CuTest* tc) {
char* key_1 = "k1";
char* k_1 = (char*)malloc(strlen(key_1) + 1);
memset(k_1, 0, strlen(key_1) + 1);
strncpy(k_1, key_1, strlen(key_1));
memcpy(k_1, key_1, strlen(key_1));

char* value_1 = "v1";
char* v_1 = (char*)malloc(strlen(value_1) + 1);
memset(v_1, 0, strlen(value_1) + 1);
strncpy(v_1, value_1, strlen(value_1));
memcpy(v_1, value_1, strlen(value_1));

arg_hashtable_insert(h, k_1, v_1);
CuAssertIntEquals(tc, 1, arg_hashtable_count(h));

char* key_2 = "k2";
char* k_2 = (char*)malloc(strlen(key_2) + 1);
memset(k_2, 0, strlen(key_2) + 1);
strncpy(k_2, key_2, strlen(key_2));
memcpy(k_2, key_2, strlen(key_2));

char* value_2 = "v2";
char* v_2 = (char*)malloc(strlen(value_2) + 1);
memset(v_2, 0, strlen(value_2) + 1);
strncpy(v_2, value_2, strlen(value_2));
memcpy(v_2, value_2, strlen(value_2));

arg_hashtable_insert(h, k_2, v_2);
CuAssertIntEquals(tc, 2, arg_hashtable_count(h));
Expand Down

0 comments on commit 76fd157

Please sign in to comment.