Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bootconfig: Replace u16 and u32 with uint16_t and uint32_t

Replace u16 and u32 with uint16_t and uint32_t so
that the tools/bootconfig only needs <stdint.h>.

Link: https://lkml.kernel.org/r/163187298835.2366983.9838262576854319669.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Masami Hiramatsu and committed by
Steven Rostedt (VMware)
4f292c48 160321b2

+25 -27
+6 -6
include/linux/bootconfig.h
··· 25 25 * The checksum will be used with the BOOTCONFIG_MAGIC and the size for 26 26 * embedding the bootconfig in the initrd image. 27 27 */ 28 - static inline __init u32 xbc_calc_checksum(void *data, u32 size) 28 + static inline __init uint32_t xbc_calc_checksum(void *data, uint32_t size) 29 29 { 30 30 unsigned char *p = data; 31 - u32 ret = 0; 31 + uint32_t ret = 0; 32 32 33 33 while (size--) 34 34 ret += *p++; ··· 38 38 39 39 /* XBC tree node */ 40 40 struct xbc_node { 41 - u16 next; 42 - u16 child; 43 - u16 parent; 44 - u16 data; 41 + uint16_t next; 42 + uint16_t child; 43 + uint16_t parent; 44 + uint16_t data; 45 45 } __attribute__ ((__packed__)); 46 46 47 47 #define XBC_KEY 0
+8 -8
lib/bootconfig.c
··· 244 244 struct xbc_node *node, 245 245 char *buf, size_t size) 246 246 { 247 - u16 keys[XBC_DEPTH_MAX]; 247 + uint16_t keys[XBC_DEPTH_MAX]; 248 248 int depth = 0, ret = 0, total = 0; 249 249 250 250 if (!node || node == root) ··· 359 359 360 360 /* XBC parse and tree build */ 361 361 362 - static int __init xbc_init_node(struct xbc_node *node, char *data, u32 flag) 362 + static int __init xbc_init_node(struct xbc_node *node, char *data, uint32_t flag) 363 363 { 364 364 unsigned long offset = data - xbc_data; 365 365 366 366 if (WARN_ON(offset >= XBC_DATA_MAX)) 367 367 return -EINVAL; 368 368 369 - node->data = (u16)offset | flag; 369 + node->data = (uint16_t)offset | flag; 370 370 node->child = 0; 371 371 node->next = 0; 372 372 373 373 return 0; 374 374 } 375 375 376 - static struct xbc_node * __init xbc_add_node(char *data, u32 flag) 376 + static struct xbc_node * __init xbc_add_node(char *data, uint32_t flag) 377 377 { 378 378 struct xbc_node *node; 379 379 ··· 403 403 return node; 404 404 } 405 405 406 - static struct xbc_node * __init __xbc_add_sibling(char *data, u32 flag, bool head) 406 + static struct xbc_node * __init __xbc_add_sibling(char *data, uint32_t flag, bool head) 407 407 { 408 408 struct xbc_node *sib, *node = xbc_add_node(data, flag); 409 409 ··· 430 430 return node; 431 431 } 432 432 433 - static inline struct xbc_node * __init xbc_add_sibling(char *data, u32 flag) 433 + static inline struct xbc_node * __init xbc_add_sibling(char *data, uint32_t flag) 434 434 { 435 435 return __xbc_add_sibling(data, flag, false); 436 436 } 437 437 438 - static inline struct xbc_node * __init xbc_add_head_sibling(char *data, u32 flag) 438 + static inline struct xbc_node * __init xbc_add_head_sibling(char *data, uint32_t flag) 439 439 { 440 440 return __xbc_add_sibling(data, flag, true); 441 441 } 442 442 443 - static inline __init struct xbc_node *xbc_add_child(char *data, u32 flag) 443 + static inline __init struct xbc_node *xbc_add_child(char *data, uint32_t flag) 444 444 { 445 445 struct xbc_node *node = xbc_add_sibling(data, flag); 446 446
+1 -3
tools/bootconfig/include/linux/kernel.h
··· 3 3 #define _SKC_LINUX_KERNEL_H 4 4 5 5 #include <stdlib.h> 6 + #include <stdint.h> 6 7 #include <stdbool.h> 7 - 8 - typedef unsigned short u16; 9 - typedef unsigned int u32; 10 8 11 9 #define unlikely(cond) (cond) 12 10
+10 -10
tools/bootconfig/main.c
··· 178 178 { 179 179 struct stat stat; 180 180 int ret; 181 - u32 size = 0, csum = 0, rcsum; 181 + uint32_t size = 0, csum = 0, rcsum; 182 182 char magic[BOOTCONFIG_MAGIC_LEN]; 183 183 const char *msg; 184 184 ··· 202 202 if (lseek(fd, -(8 + BOOTCONFIG_MAGIC_LEN), SEEK_END) < 0) 203 203 return pr_errno("Failed to lseek for size", -errno); 204 204 205 - if (read(fd, &size, sizeof(u32)) < 0) 205 + if (read(fd, &size, sizeof(uint32_t)) < 0) 206 206 return pr_errno("Failed to read size", -errno); 207 207 size = le32toh(size); 208 208 209 - if (read(fd, &csum, sizeof(u32)) < 0) 209 + if (read(fd, &csum, sizeof(uint32_t)) < 0) 210 210 return pr_errno("Failed to read checksum", -errno); 211 211 csum = le32toh(csum); 212 212 ··· 364 364 size_t total_size; 365 365 struct stat stat; 366 366 const char *msg; 367 - u32 size, csum; 367 + uint32_t size, csum; 368 368 int pos, pad; 369 369 int ret, fd; 370 370 ··· 378 378 379 379 /* Backup the bootconfig data */ 380 380 data = calloc(size + BOOTCONFIG_ALIGN + 381 - sizeof(u32) + sizeof(u32) + BOOTCONFIG_MAGIC_LEN, 1); 381 + sizeof(uint32_t) + sizeof(uint32_t) + BOOTCONFIG_MAGIC_LEN, 1); 382 382 if (!data) 383 383 return -ENOMEM; 384 384 memcpy(data, buf, size); ··· 426 426 } 427 427 428 428 /* To align up the total size to BOOTCONFIG_ALIGN, get padding size */ 429 - total_size = stat.st_size + size + sizeof(u32) * 2 + BOOTCONFIG_MAGIC_LEN; 429 + total_size = stat.st_size + size + sizeof(uint32_t) * 2 + BOOTCONFIG_MAGIC_LEN; 430 430 pad = ((total_size + BOOTCONFIG_ALIGN - 1) & (~BOOTCONFIG_ALIGN_MASK)) - total_size; 431 431 size += pad; 432 432 433 433 /* Add a footer */ 434 434 p = data + size; 435 - *(u32 *)p = htole32(size); 436 - p += sizeof(u32); 435 + *(uint32_t *)p = htole32(size); 436 + p += sizeof(uint32_t); 437 437 438 - *(u32 *)p = htole32(csum); 439 - p += sizeof(u32); 438 + *(uint32_t *)p = htole32(csum); 439 + p += sizeof(uint32_t); 440 440 441 441 memcpy(p, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN); 442 442 p += BOOTCONFIG_MAGIC_LEN;