diff options
author | J. Richard Barnette <jrbarnette@chromium.org> | 2013-10-30 11:36:45 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-10-31 21:56:58 +0000 |
commit | a3d70a3d2b5c052db039d097aaffa42008da24b5 (patch) | |
tree | 40263855d5eef64cea1c729e89397d0f4cef4880 /host/include/crossystem.h | |
parent | fe2c1a231e3893dc3d7ac314e11b04a18c6948e7 (diff) | |
download | vboot-a3d70a3d2b5c052db039d097aaffa42008da24b5.tar.gz |
Make crossystem.h more polite and more useful.test-4980.Btest-4824.Bstabilize-R33-4982.Bstabilize-5062.Bstabilize-4920.6.Brelease-R32-4920.Bfirmware-bolt_kirby-4979.Bfactory-panther-4920.23.B
This adds a VB_MAX_STRING_PROPERTY for callers that don't
want to guess at how big to make their buffers.
Additionally, it changes the size parameter to VbGetPropertyString()
from int to size_t.
BUG=None
TEST=compile the code
BRANCH=none
Change-Id: I22809d48e13b535593cb22a56444e2dcb27791a5
Reviewed-on: https://chromium-review.googlesource.com/175039
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Richard Barnette <jrbarnette@chromium.org>
Diffstat (limited to 'host/include/crossystem.h')
-rw-r--r-- | host/include/crossystem.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/host/include/crossystem.h b/host/include/crossystem.h index c116b0c2..25b9cc0b 100644 --- a/host/include/crossystem.h +++ b/host/include/crossystem.h @@ -10,6 +10,12 @@ extern "C" { #endif +#include <stddef.h> + +/* Recommended size for string property buffers used with + * VbGetSystemPropertyString(). */ +#define VB_MAX_STRING_PROPERTY ((size_t) 8192) + /* Reads a system property integer. * * Returns the property value, or -1 if error. */ @@ -19,8 +25,12 @@ int VbGetSystemPropertyInt(const char* name); * specified size. Returned string will be null-terminated. If the * buffer is too small, the returned string will be truncated. * + * The caller can expect an un-truncated value if the size provided is + * at least VB_MAX_STRING_PROPERTY. + * * Returns the passed buffer, or NULL if error. */ -const char* VbGetSystemPropertyString(const char* name, char* dest, int size); +const char* VbGetSystemPropertyString(const char* name, char* dest, + size_t size); /* Sets a system property integer. * @@ -29,6 +39,9 @@ int VbSetSystemPropertyInt(const char* name, int value); /* Set a system property string. * + * The maximum length of the value accepted depends on the specific + * property, not on VB_MAX_STRING_PROPERTY. + * * Returns 0 if success, -1 if error. */ int VbSetSystemPropertyString(const char* name, const char* value); |