WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #75: new file mode 100644 WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 #80: FILE: tools/kexec/pe.h:1: +/* WARNING: Block comments use a trailing */ on a separate line #125: FILE: tools/kexec/pe.h:46: + * work right. vomit. */ WARNING: Block comments use * on subsequent lines #150: 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 #150: FILE: tools/kexec/pe.h:71: + file_align */ WARNING: Block comments use * on subsequent lines #184: 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 #184: FILE: tools/kexec/pe.h:105: + file_align */ WARNING: line length of 82 exceeds 80 columns #212: FILE: tools/kexec/pe.h:133: + struct data_dirent load_config; /* load configuration structure */ WARNING: do not add new typedefs #287: FILE: tools/kexec/zboot_image_builder.c:25: +typedef struct { WARNING: Prefer __packed over __attribute__((packed)) #303: FILE: tools/kexec/zboot_image_builder.c:41: +} __attribute__((packed)) pe_zboot_header; WARNING: do not add new typedefs #305: FILE: tools/kexec/zboot_image_builder.c:43: +typedef unsigned long uintptr_t; WARNING: line length of 90 exceeds 80 columns #306: 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 #306: 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) #323: 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 #324: FILE: tools/kexec/zboot_image_builder.c:62: + fprintf(stderr, "Usage: %s \n", argv[0]); WARNING: Statements should start on a tabstop #325: FILE: tools/kexec/zboot_image_builder.c:63: + return -1; WARNING: Missing a blank line after declarations #332: 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) #332: FILE: tools/kexec/zboot_image_builder.c:70: + if (!bin_fp) { + perror("Failed to open binary file"); WARNING: Statements should start on a tabstop #334: FILE: tools/kexec/zboot_image_builder.c:72: + return -1; WARNING: Missing a blank line after declarations #338: 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) #341: 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) #346: 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 #350: 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) #351: 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) #363: 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) #369: 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 #371: FILE: tools/kexec/zboot_image_builder.c:109: + return -1; WARNING: line length of 81 exceeds 80 columns #373: 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 #374: 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) #376: 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) #376: FILE: tools/kexec/zboot_image_builder.c:114: + if (pe_hdr->magic!= 0x00004550) { // 'PE\0\0' ^ WARNING: Statements should start on a tabstop #378: FILE: tools/kexec/zboot_image_builder.c:116: + return -1; WARNING: line length of 101 exceeds 80 columns #387: 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 #388: 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 #388: 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) #391: 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 #393: FILE: tools/kexec/zboot_image_builder.c:131: + if (zheader->payload_offset >= sect->data_addr && WARNING: suspect code indent for conditional statements (12, 20) #393: 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 #394: 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 #396: FILE: tools/kexec/zboot_image_builder.c:134: + payload_sect_off = zheader->payload_offset - sect->data_addr; WARNING: Statements should start on a tabstop #397: FILE: tools/kexec/zboot_image_builder.c:135: + } WARNING: suspect code indent for conditional statements (8, 12) #401: 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 #402: 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 #402: 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 #403: FILE: tools/kexec/zboot_image_builder.c:141: + if (section_end > max_va_end) { WARNING: Missing a blank line after declarations #403: 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 #403: 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 #404: FILE: tools/kexec/zboot_image_builder.c:142: +^I max_va_end = section_end;$ WARNING: Statements should start on a tabstop #405: FILE: tools/kexec/zboot_image_builder.c:143: + } WARNING: Missing a blank line after declarations #412: 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 #414: 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 #417: 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 #419: 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 #420: 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) #420: 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 #422: FILE: tools/kexec/zboot_image_builder.c:160: + return -1; WARNING: line length of 94 exceeds 80 columns #424: 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 #427: 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 #428: 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: Prefer strscpy, strscpy_pad, or __nonstring over strncpy - see: https://github.com/KSPP/linux/issues/90 #429: FILE: tools/kexec/zboot_image_builder.c:167: + strncpy((char *)bpf_section->name, ".bpf", 8); WARNING: line length of 94 exceeds 80 columns #436: 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 #437: 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 #440: 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 #443: 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 #445: FILE: tools/kexec/zboot_image_builder.c:183: + + WARNING: suspect code indent for conditional statements (16, 20) #452: 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 #454: 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 #459: FILE: tools/kexec/zboot_image_builder.c:197: + uint32_t t; + i = new_hdr->sections - 2; WARNING: line length of 89 exceeds 80 columns #465: 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 #470: 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 #472: FILE: tools/kexec/zboot_image_builder.c:210: + + WARNING: line length of 89 exceeds 80 columns #488: 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 #496: 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 #502: 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) #518: FILE: tools/kexec/zboot_image_builder.c:256: + if (out_cur + bin_size > out_start_addr + out_sz) { + perror("out of out_fd mmap\n"); WARNING: Statements should start on a tabstop #521: FILE: tools/kexec/zboot_image_builder.c:259: + goto err; total: 3 errors, 71 warnings, 2 checks, 479 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 4ccaf38ec040 ("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 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.