WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 #71: FILE: tools/kexec/pe.h:1: +/* WARNING: Block comments use a trailing */ on a separate line #116: FILE: tools/kexec/pe.h:46: + * work right. vomit. */ WARNING: Block comments use * on subsequent lines #141: FILE: tools/kexec/pe.h:71: + uint32_t header_size; /* header size rounded up to + file_align */ WARNING: Block comments use a trailing */ on a separate line #141: FILE: tools/kexec/pe.h:71: + file_align */ WARNING: Block comments use * on subsequent lines #175: FILE: tools/kexec/pe.h:105: + uint32_t header_size; /* header size rounded up to + file_align */ WARNING: Block comments use a trailing */ on a separate line #175: FILE: tools/kexec/pe.h:105: + file_align */ WARNING: line length of 82 exceeds 80 columns #203: FILE: tools/kexec/pe.h:133: + struct data_dirent load_config; /* load configuration structure */ WARNING: do not add new typedefs #278: FILE: tools/kexec/zboot_image_builder.c:25: +typedef struct { WARNING: Prefer __packed over __attribute__((packed)) #294: FILE: tools/kexec/zboot_image_builder.c:41: +} __attribute__((packed)) pe_zboot_header; WARNING: do not add new typedefs #296: FILE: tools/kexec/zboot_image_builder.c:43: +typedef unsigned long uintptr_t; WARNING: line length of 90 exceeds 80 columns #297: FILE: tools/kexec/zboot_image_builder.c:44: +#define ALIGN_UP(p, size) (__typeof__(p))(((uintptr_t)(p) + ((size) - 1)) & ~((size) - 1)) ERROR: Macros with complex values should be enclosed in parentheses #297: FILE: tools/kexec/zboot_image_builder.c:44: +#define ALIGN_UP(p, size) (__typeof__(p))(((uintptr_t)(p) + ((size) - 1)) & ~((size) - 1)) BUT SEE: do {} while (0) advice is over-stated in a few situations: The more obvious case is macros, like MODULE_PARM_DESC, invoked at file-scope, where C disallows code (it must be in functions). See $exceptions if you have one to add by name. More troublesome is declarative macros used at top of new scope, like DECLARE_PER_CPU. These might just compile with a do-while-0 wrapper, but would be incorrect. Most of these are handled by detecting struct,union,etc declaration primitives in $exceptions. Theres also macros called inside an if (block), which "return" an expression. These cannot do-while, and need a ({}) wrapper. Enjoy this qualification while we work to improve our heuristics. WARNING: suspect code indent for conditional statements (8, 12) #314: FILE: tools/kexec/zboot_image_builder.c:61: + if (argc != 4) { + fprintf(stderr, "Usage: %s \n", argv[0]); WARNING: line length of 89 exceeds 80 columns #315: FILE: tools/kexec/zboot_image_builder.c:62: + fprintf(stderr, "Usage: %s \n", argv[0]); WARNING: Statements should start on a tabstop #316: FILE: tools/kexec/zboot_image_builder.c:63: + return -1; WARNING: Missing a blank line after declarations #323: FILE: tools/kexec/zboot_image_builder.c:70: + FILE *bin_fp = fopen(binary_file, "rb"); + if (!bin_fp) { WARNING: suspect code indent for conditional statements (8, 12) #323: FILE: tools/kexec/zboot_image_builder.c:70: + if (!bin_fp) { + perror("Failed to open binary file"); WARNING: Statements should start on a tabstop #325: FILE: tools/kexec/zboot_image_builder.c:72: + return -1; WARNING: Missing a blank line after declarations #329: FILE: tools/kexec/zboot_image_builder.c:76: + size_t bin_size = ftell(bin_fp); + fseek(bin_fp, 0, SEEK_SET); WARNING: suspect code indent for conditional statements (8, 12) #332: FILE: tools/kexec/zboot_image_builder.c:79: + if (base_fd == -1 || out_fd == -1) { + perror("Error opening file"); WARNING: suspect code indent for conditional statements (8, 12) #337: FILE: tools/kexec/zboot_image_builder.c:84: + if (fstat(base_fd, &sb) == -1) { + perror("Error getting file size"); WARNING: line length of 84 exceeds 80 columns #341: FILE: tools/kexec/zboot_image_builder.c:88: + base_start_addr = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, base_fd, 0); WARNING: suspect code indent for conditional statements (8, 12) #342: FILE: tools/kexec/zboot_image_builder.c:89: + if (base_start_addr == MAP_FAILED) { + perror("Error mmapping the file"); WARNING: suspect code indent for conditional statements (8, 12) #354: FILE: tools/kexec/zboot_image_builder.c:101: + if (out_start_addr == MAP_FAILED) { + perror("Error mmapping the file"); WARNING: suspect code indent for conditional statements (8, 12) #360: FILE: tools/kexec/zboot_image_builder.c:107: + if (zheader->mz_magic != 0x5A4D) { // 'MZ' + fprintf(stderr, "Invalid DOS signature\n"); WARNING: Statements should start on a tabstop #362: FILE: tools/kexec/zboot_image_builder.c:109: + return -1; WARNING: line length of 81 exceeds 80 columns #364: FILE: tools/kexec/zboot_image_builder.c:111: + uint32_t pe_hdr_offset = get_pehdr_offset((const char *)base_start_addr); WARNING: Missing a blank line after declarations #365: FILE: tools/kexec/zboot_image_builder.c:112: + uint32_t pe_hdr_offset = get_pehdr_offset((const char *)base_start_addr); + base_cur = base_start_addr + pe_hdr_offset; WARNING: suspect code indent for conditional statements (8, 12) #367: FILE: tools/kexec/zboot_image_builder.c:114: + if (pe_hdr->magic!= 0x00004550) { // 'PE\0\0' + fprintf(stderr, "Invalid PE signature\n"); ERROR: spaces required around that '!=' (ctx:VxW) #367: FILE: tools/kexec/zboot_image_builder.c:114: + if (pe_hdr->magic!= 0x00004550) { // 'PE\0\0' ^ WARNING: Statements should start on a tabstop #369: FILE: tools/kexec/zboot_image_builder.c:116: + return -1; WARNING: line length of 101 exceeds 80 columns #378: FILE: tools/kexec/zboot_image_builder.c:125: + uint32_t section_table_offset = pe_hdr_offset + sizeof(struct pe_hdr) + pe_hdr->opt_hdr_size; WARNING: line length of 90 exceeds 80 columns #379: FILE: tools/kexec/zboot_image_builder.c:126: + base_sections = (struct section_header *)(base_start_addr + section_table_offset); WARNING: Missing a blank line after declarations #379: FILE: tools/kexec/zboot_image_builder.c:126: + uint32_t section_table_offset = pe_hdr_offset + sizeof(struct pe_hdr) + pe_hdr->opt_hdr_size; + base_sections = (struct section_header *)(base_start_addr + section_table_offset); WARNING: suspect code indent for conditional statements (8, 12) #382: FILE: tools/kexec/zboot_image_builder.c:129: + for (i = 0; i < num_sections; i++) { + sect = &base_sections[i]; WARNING: Statements should start on a tabstop #384: FILE: tools/kexec/zboot_image_builder.c:131: + if (zheader->payload_offset >= sect->data_addr && WARNING: suspect code indent for conditional statements (12, 20) #384: FILE: tools/kexec/zboot_image_builder.c:131: + if (zheader->payload_offset >= sect->data_addr && [...] + payload_sect_idx = i; WARNING: line length of 84 exceeds 80 columns #385: FILE: tools/kexec/zboot_image_builder.c:132: + zheader->payload_offset < (sect->data_addr + sect->raw_data_size)) { WARNING: line length of 81 exceeds 80 columns #387: FILE: tools/kexec/zboot_image_builder.c:134: + payload_sect_off = zheader->payload_offset - sect->data_addr; WARNING: Statements should start on a tabstop #388: FILE: tools/kexec/zboot_image_builder.c:135: + } WARNING: suspect code indent for conditional statements (8, 12) #392: FILE: tools/kexec/zboot_image_builder.c:139: + for (i = 0; i < num_sections; i++) { + uint32_t section_end = base_sections[i].virtual_address + base_sections[i].virtual_size; WARNING: line length of 100 exceeds 80 columns #393: FILE: tools/kexec/zboot_image_builder.c:140: + uint32_t section_end = base_sections[i].virtual_address + base_sections[i].virtual_size; WARNING: Statements should start on a tabstop #393: FILE: tools/kexec/zboot_image_builder.c:140: + uint32_t section_end = base_sections[i].virtual_address + base_sections[i].virtual_size; WARNING: Statements should start on a tabstop #394: FILE: tools/kexec/zboot_image_builder.c:141: + if (section_end > max_va_end) { WARNING: Missing a blank line after declarations #394: FILE: tools/kexec/zboot_image_builder.c:141: + uint32_t section_end = base_sections[i].virtual_address + base_sections[i].virtual_size; + if (section_end > max_va_end) { WARNING: braces {} are not necessary for single statement blocks #394: FILE: tools/kexec/zboot_image_builder.c:141: + if (section_end > max_va_end) { + max_va_end = section_end; + } ERROR: code indent should use tabs where possible #395: FILE: tools/kexec/zboot_image_builder.c:142: +^I max_va_end = section_end;$ WARNING: Statements should start on a tabstop #396: FILE: tools/kexec/zboot_image_builder.c:143: + } WARNING: Missing a blank line after declarations #403: FILE: tools/kexec/zboot_image_builder.c:150: + pe_zboot_header *new_zhdr = malloc(sizeof(pe_zboot_header)); + memcpy(new_zhdr, zheader, sizeof(pe_zboot_header)); WARNING: Missing a blank line after declarations #405: FILE: tools/kexec/zboot_image_builder.c:152: + struct pe_hdr *new_hdr = malloc(sizeof(struct pe_hdr)); + memcpy(new_hdr, pe_hdr, sizeof(struct pe_hdr)); WARNING: Missing a blank line after declarations #408: FILE: tools/kexec/zboot_image_builder.c:155: + struct pe32plus_opt_hdr *new_opt_hdr = malloc(pe_hdr->opt_hdr_size); + memcpy(new_opt_hdr, opt_hdr, pe_hdr->opt_hdr_size); WARNING: line length of 107 exceeds 80 columns #410: FILE: tools/kexec/zboot_image_builder.c:157: + struct section_header *new_sections = calloc(1, new_hdr->sections * sizeof(struct section_header)); WARNING: Missing a blank line after declarations #411: FILE: tools/kexec/zboot_image_builder.c:158: + struct section_header *new_sections = calloc(1, new_hdr->sections * sizeof(struct section_header)); + if (!new_sections) { WARNING: suspect code indent for conditional statements (8, 12) #411: FILE: tools/kexec/zboot_image_builder.c:158: + if (!new_sections) { + perror("Failed to allocate memory for new section headers"); WARNING: Statements should start on a tabstop #413: FILE: tools/kexec/zboot_image_builder.c:160: + return -1; WARNING: line length of 94 exceeds 80 columns #415: FILE: tools/kexec/zboot_image_builder.c:162: + memcpy(new_sections, base_sections, pe_hdr->sections * sizeof(struct section_header)); WARNING: line length of 82 exceeds 80 columns #418: FILE: tools/kexec/zboot_image_builder.c:165: + struct section_header *bpf_section = &new_sections[new_hdr->sections - 1]; WARNING: Missing a blank line after declarations #419: FILE: tools/kexec/zboot_image_builder.c:166: + struct section_header *bpf_section = &new_sections[new_hdr->sections - 1]; + memset(bpf_section, 0, sizeof(struct section_header)); WARNING: line length of 94 exceeds 80 columns #427: FILE: tools/kexec/zboot_image_builder.c:174: + uint32_t new_size_of_image = bpf_section->virtual_address + bpf_section->virtual_size; WARNING: Missing a blank line after declarations #428: FILE: tools/kexec/zboot_image_builder.c:175: + uint32_t new_size_of_image = bpf_section->virtual_address + bpf_section->virtual_size; + new_size_of_image = ALIGN_UP(new_size_of_image, section_alignment); WARNING: line length of 88 exceeds 80 columns #431: FILE: tools/kexec/zboot_image_builder.c:178: + size_t section_table_size = new_hdr->sections * (sizeof(struct section_header)); WARNING: Missing a blank line after declarations #434: FILE: tools/kexec/zboot_image_builder.c:181: + size_t aligned_headers_size = ALIGN_UP(headers_size, file_align); + new_opt_hdr->header_size = aligned_headers_size; CHECK: Please don't use multiple blank lines #436: FILE: tools/kexec/zboot_image_builder.c:183: + + WARNING: suspect code indent for conditional statements (16, 20) #443: FILE: tools/kexec/zboot_image_builder.c:190: + for (i = 0; i < new_hdr->sections; i++) { + new_sections[i].data_addr = current_offset; WARNING: line length of 90 exceeds 80 columns #445: FILE: tools/kexec/zboot_image_builder.c:192: + current_offset += ALIGN_UP(new_sections[i].raw_data_size, file_align); WARNING: Missing a blank line after declarations #450: FILE: tools/kexec/zboot_image_builder.c:197: + uint32_t t; + i = new_hdr->sections - 2; WARNING: line length of 89 exceeds 80 columns #456: FILE: tools/kexec/zboot_image_builder.c:203: + payload_new_offset = new_sections[payload_sect_idx].data_addr + payload_sect_off; WARNING: line length of 85 exceeds 80 columns #461: FILE: tools/kexec/zboot_image_builder.c:208: + zheader->payload_offset, payload_new_offset, new_zhdr->payload_size); CHECK: Please don't use multiple blank lines #463: FILE: tools/kexec/zboot_image_builder.c:210: + + WARNING: line length of 89 exceeds 80 columns #479: FILE: tools/kexec/zboot_image_builder.c:226: + memcpy(out_cur, new_sections, new_hdr->sections * sizeof(struct section_header)); WARNING: line length of 99 exceeds 80 columns #487: FILE: tools/kexec/zboot_image_builder.c:234: + msync(out_start_addr, new_sections[i].data_addr + new_sections[i].raw_data_size, MS_ASYNC); WARNING: Missing a blank line after declarations #493: FILE: tools/kexec/zboot_image_builder.c:240: + char *bin_data = calloc(1, bin_size); + if (!bin_data) { WARNING: suspect code indent for conditional statements (8, 12) #507: FILE: tools/kexec/zboot_image_builder.c:254: + if (out_cur + bin_size > out_start_addr + out_sz) { + perror("out of out_fd mmap\n"); WARNING: Statements should start on a tabstop #510: FILE: tools/kexec/zboot_image_builder.c:257: + goto err; total: 3 errors, 69 warnings, 2 checks, 477 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. NOTE: Whitespace errors detected. You may wish to use scripts/cleanpatch or scripts/cleanfile Commit 7a0750680df2 ("tools/kexec: Add a zboot image building tool") has style problems, please review. NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT BAD_REPORTED_BY_LINK CAMELCASE COMMIT_LOG_LONG_LINE FILE_PATH_CHANGES GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.