Skip to content

Commit 4f3da3d

Browse files
SergiiDmytrukvathpela
authored andcommitted
export.c: don't use char16_t
<uchar.h> is glibc-specific and it's not even guaranteed to be 2 bytes long! typedef __uint_least16_t char16_t; uint16_t seems much more appropriate here. Signed-off-by: Sergii Dmytruk <[email protected]>
1 parent 4a5dfbf commit 4f3da3d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/export.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <inttypes.h>
1010
#include <stdint.h>
1111
#include <stdlib.h>
12-
#include <uchar.h>
1312

1413
#include "efivar.h"
1514

@@ -26,7 +25,7 @@
2625
* efi_guid_t guid;
2726
* uint32_t name_len;
2827
* uint32_t data_len;
29-
* char16_t name[];
28+
* uint16_t name[];
3029
* uint8_t data[];
3130
* uint32_t crc32;
3231
* }
@@ -35,7 +34,7 @@
3534
* struct {
3635
* uint32_t name_size; // in bytes
3736
* uint32_t data_size; // in bytes
38-
* char16_t name[];
37+
* uint16_t name[];
3938
* efi_guid_t guid;
4039
* uint32_t attr;
4140
* unit8_t data[];
@@ -56,7 +55,7 @@ efi_variable_import_dmpstore(uint8_t *data, size_t size,
5655
uint32_t datasz;
5756
size_t min = sizeof (uint32_t) /* name size */
5857
+ sizeof (uint32_t) /* data size */
59-
+ sizeof (char16_t) /* two bytes of name */
58+
+ sizeof (uint16_t) /* two bytes of name */
6059
+ sizeof (efi_guid_t) /* guid */
6160
+ sizeof (uint32_t) /* attr */
6261
+ 1 /* one byte of data */
@@ -195,7 +194,7 @@ efi_variable_import_efivar(uint8_t *data, size_t datasz, efi_variable_t **var_ou
195194
+ sizeof (uint64_t) /* attr */
196195
+ sizeof (efi_guid_t) /* guid */
197196
+ sizeof (uint32_t) * 2 /* name_len and data_len */
198-
+ sizeof (char16_t) /* two bytes of name */
197+
+ sizeof (uint16_t) /* two bytes of name */
199198
+ 1 /* one byte of data */
200199
+ 4; /* crc32 */
201200
uint32_t crc;
@@ -276,7 +275,7 @@ efi_variable_import_efivar(uint8_t *data, size_t datasz, efi_variable_t **var_ou
276275
return -1;
277276
}
278277

279-
char16_t *wname = (char16_t *)ptr;
278+
uint16_t *wname = (uint16_t *)ptr;
280279
for (uint32_t i = 0; i < name_len; i++)
281280
var.name[i] = wname[i] & 0xff;
282281
ptr += name_len;

0 commit comments

Comments
 (0)