-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved string functions to the .c where they belong (#481)
* Moved string functions to the .c where they belong * fix CBMC tests by adding string.c * moved functions back inline as requested in PR
- Loading branch information
Showing
11 changed files
with
246 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
jobos: ubuntu16 | ||
cbmcflags: "--bounds-check;--div-by-zero-check;--float-overflow-check;--nan-check;--pointer-check;--pointer-overflow-check;--signed-overflow-check;--undefined-shift-check;--unsigned-overflow-check;--unwind;1;--unwinding-assertions;--unwindset;strlen.0:33,__CPROVER_file_local_lookup3_inl_hashlittle2.0:3,__CPROVER_file_local_lookup3_inl_hashlittle2.1:3,__CPROVER_file_local_lookup3_inl_hashlittle2.2:3;--object-bits;8" | ||
goto: aws_hash_c_string_harness.goto | ||
expected: "SUCCESSFUL" | ||
goto: aws_hash_c_string_harness.goto | ||
jobos: ubuntu16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
jobos: ubuntu16 | ||
cbmcflags: "--bounds-check;--div-by-zero-check;--float-overflow-check;--nan-check;--pointer-check;--pointer-overflow-check;--signed-overflow-check;--undefined-shift-check;--unsigned-overflow-check;--unwind;1;--unwinding-assertions;--unwindset;strcmp.0:65,strlen.0:65;--object-bits;8" | ||
goto: aws_hash_callback_c_str_eq_harness.goto | ||
expected: "SUCCESSFUL" | ||
goto: aws_hash_callback_c_str_eq_harness.goto | ||
jobos: ubuntu16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
jobos: ubuntu16 | ||
cbmcflags: "--bounds-check;--div-by-zero-check;--float-overflow-check;--nan-check;--pointer-check;--pointer-overflow-check;--signed-overflow-check;--undefined-shift-check;--unsigned-overflow-check;--unwind;1;--unwinding-assertions;--unwindset;memcmp.0:97;--object-bits;8" | ||
goto: aws_hash_callback_string_eq_harness.goto | ||
expected: "SUCCESSFUL" | ||
goto: aws_hash_callback_string_eq_harness.goto | ||
jobos: ubuntu16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
jobos: ubuntu16 | ||
cbmcflags: "--bounds-check;--div-by-zero-check;--float-overflow-check;--nan-check;--pointer-check;--pointer-overflow-check;--signed-overflow-check;--undefined-shift-check;--unsigned-overflow-check;--unwind;1;--unwinding-assertions;--unwindset;__CPROVER_file_local_lookup3_inl_hashlittle2.0:3,__CPROVER_file_local_lookup3_inl_hashlittle2.1:3,__CPROVER_file_local_lookup3_inl_hashlittle2.2:3;--object-bits;8" | ||
goto: aws_hash_string_harness.goto | ||
expected: "SUCCESSFUL" | ||
goto: aws_hash_string_harness.goto | ||
jobos: ubuntu16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#ifndef AWS_COMMON_STRING_INL | ||
#define AWS_COMMON_STRING_INL | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
/** | ||
* Equivalent to str->bytes. | ||
*/ | ||
AWS_STATIC_IMPL | ||
const uint8_t *aws_string_bytes(const struct aws_string *str) { | ||
AWS_PRECONDITION(aws_string_is_valid(str)); | ||
return str->bytes; | ||
} | ||
|
||
/** | ||
* Evaluates the set of properties that define the shape of all valid aws_string structures. | ||
* It is also a cheap check, in the sense it run in constant time (i.e., no loops or recursion). | ||
*/ | ||
AWS_STATIC_IMPL | ||
bool aws_string_is_valid(const struct aws_string *str) { | ||
return str && AWS_MEM_IS_READABLE(&str->bytes[0], str->len + 1) && str->bytes[str->len] == 0; | ||
} | ||
|
||
/** | ||
* Best-effort checks aws_string invariants, when the str->len is unknown | ||
*/ | ||
AWS_STATIC_IMPL | ||
bool aws_c_string_is_valid(const char *str) { | ||
/* Knowing the actual length to check would require strlen(), which is | ||
* a) linear time in the length of the string | ||
* b) could already cause a memory violation for a non-zero-terminated string. | ||
* But we know that a c-string must have at least one character, to store the null terminator | ||
*/ | ||
return str && AWS_MEM_IS_READABLE(str, 1); | ||
} | ||
|
||
#endif /* AWS_COMMON_STRING_INL */ |
Oops, something went wrong.