Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1259)

Unified Diff: cgpt/cgpt.h

Issue 5025003: The right implementation of CGPT label conversion between UTF8 and UTF16. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: Fixed per code review opinion. Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cgpt/cgpt_common.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cgpt/cgpt.h
diff --git a/cgpt/cgpt.h b/cgpt/cgpt.h
index 9b0805cfb688c4984f1138e9b6fc3099b85009b5..85702a4f6035d0cfde6de592b8c8e47241431e98 100644
--- a/cgpt/cgpt.h
+++ b/cgpt/cgpt.h
@@ -81,14 +81,22 @@ int WritePMBR(struct drive *drive);
/* Convert possibly unterminated UTF16 string to UTF8.
* Caller must prepare enough space for UTF8, which could be up to
- * twice the number of UTF16 chars plus the terminating '\0'.
+ * twice the byte length of UTF16 string plus the terminating '\0'.
+ *
+ * Return: CGPT_OK --- all character are converted successfully.
+ * CGPT_FAILED --- convert error, i.e. output buffer is too short.
*/
-void UTF16ToUTF8(const uint16_t *utf16, unsigned int maxinput,
- uint8_t *utf8, unsigned int maxoutput);
+int UTF16ToUTF8(const uint16_t *utf16, unsigned int maxinput,
+ uint8_t *utf8, unsigned int maxoutput);
+
/* Convert null-terminated UTF8 string to UTF16.
- * Caller must prepare enough space for UTF16, including a terminating 0x0000
+ * Caller must prepare enough space for UTF16, which is the byte length of UTF8
+ * plus the terminating 0x0000.
+ *
+ * Return: CGPT_OK --- all character are converted successfully.
+ * CGPT_FAILED --- convert error, i.e. output buffer is too short.
*/
-void UTF8ToUTF16(const uint8_t *utf8, uint16_t *utf16, unsigned int maxoutput);
+int UTF8ToUTF16(const uint8_t *utf8, uint16_t *utf16, unsigned int maxoutput);
/* Helper functions for supported GPT types. */
int ResolveType(const Guid *type, char *buf);
« no previous file with comments | « no previous file | cgpt/cgpt_common.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698