summaryrefslogtreecommitdiff
path: root/drivers/message/i2o/git@git.tavy.me:linux.git
diff options
context:
space:
mode:
authorHuiwen He <hehuiwen@kylinos.cn>2026-04-02 14:18:35 +0000
committerSteve French <stfrench@microsoft.com>2026-04-05 19:58:40 -0500
commitcd4e653a2f75517b4ba8a0589856aeb529a27871 (patch)
treeb6e857b3f34fe787884f3d13676a24deaf8d7ca6 /drivers/message/i2o/git@git.tavy.me:linux.git
parent669c3eedaefa9cce6d87ccdb3864cf9bb606f325 (diff)
smb/client: annotate smberr.h with POSIX error codes
Annotate SMB1 error definitions in smberr.h with their corresponding POSIX error codes. To facilitate automated processing and ensure consistent formatting, existing inline comments (/* ... */) in smberr.h were first moved to the lines preceding the #define statements. This provides the source data for generating sorted mapping tables, allowing the implementation of binary search for faster error mapping lookups in later commits. The annotations were performed based on the manual mapping_table_ERRDOS[] and mapping_table_ERRSRV[] arrays in smb1maperror.c using the following python script: #!/usr/bin/env python3 import re import os MAP_FILE = "fs/smb/client/smb1maperror.c" SMBERR_FILE = "fs/smb/client/smberr.h" def get_mappings(): mappings = {} if not os.path.exists(MAP_FILE): return mappings with open(MAP_FILE, "r") as f: content = f.read() for table in ["mapping_table_ERRDOS", "mapping_table_ERRSRV"]: pattern = ( rf'static const struct smb_to_posix_error {table}\[\] = ' r'\{([\s\S]+?)\};' ) match = re.search(pattern, content) if match: entry_pattern = ( r'\{\s*([A-Za-z0-9_]+)\s*,\s*' r'(-[A-Z0-9_]+)\s*\}' ) entries = re.findall(entry_pattern, match.group(1)) for name, posix in entries: if name != "0": mappings[name] = posix return mappings def format_comment(comment_lines): """ Formats comment lines to comply with Linux kernel coding style. Single-line comments remain on one line. Multi-line comments use the standard block format. """ raw_text = [] for line in comment_lines: line = line.strip() if line.startswith('/*'): line = line[2:] if line.endswith('*/'): line = line[:-2] line = line.lstrip(' *').strip() if line: raw_text.append(line) if not raw_text: return [] # If it's a single line of text, keep it simple if len(raw_text) == 1: return [f"/* {raw_text[0]} */"] # Multi-line: Standard Kernel Block Comment Format formatted = ["/*"] for text in raw_text: formatted.append(f" * {text}") formatted.append(" */") return formatted def fix_content(content, mappings): lines = content.splitlines() new_lines, i = [], 0 while i < len(lines): line = lines[i] # Match #define with inline comment define_re = ( r'^(\s*#define\s+([A-Za-z0-9_]+)\s+' r'[^\s/]+)\s*/\*' ) match = re.match(define_re, line) if match: prefix, name = match.group(1), match.group(2) # Extract full comment block comment_block = [line[line.find('/*'):].strip()] if '*/' not in line: while i + 1 < len(lines): i += 1 comment_block.append(lines[i].strip()) if '*/' in lines[i]: break # Format and add comment new_lines.extend(format_comment(comment_block)) # Add define with tab-separated POSIX code new_define = prefix.rstrip() if name in mappings: new_define += '\t// ' + mappings[name] new_lines.append(new_define) else: no_comment_re = ( r'^(\s*#define\s+([A-Za-z0-9_]+)\s+' r'[^\s/]+)\s*$' ) match_no_comment = re.match(no_comment_re, line) if match_no_comment: prefix = match_no_comment.group(1) name = match_no_comment.group(2) new_define = prefix.rstrip() if name in mappings: new_define += '\t// ' + mappings[name] new_lines.append(new_define) else: new_lines.append(line) i += 1 return '\n'.join(new_lines) if __name__ == "__main__": m = get_mappings() if os.path.exists(SMBERR_FILE): with open(SMBERR_FILE, "r") as f: content = f.read() fixed = fix_content(content, m) with open(SMBERR_FILE, "w") as f: f.write(fixed + '\n') print(f"Successfully processed {SMBERR_FILE}") Signed-off-by: Huiwen He <hehuiwen@kylinos.cn> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'drivers/message/i2o/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions