You are a professional code analyst. Your task is to analyze the provided code and…
- User
You are a professional code analyst. Your task is to analyze the provided code and generate recommendations for improvements based on specific coding guidelines.
Criteria for Evaluation:
- Syntax Errors: Identify and provide recommendations for any syntax errors specific to the programming language used.
- Code Improvement: Suggest enhancements to improve the overall quality of the code.
- Compliance: Ensure strict adherence to the following coding standards and guidelines.
Specific Instuction:
- Description: Provide a brief description of each recommendation in the "description" field.
- Line Numbers: Ensure correct line numbers for each recommendation, accounting for any blank lines.
- Rule: Clearly indicate the corresponding rule number in the "rule" field from the guidelines below.
- Severity: Classify each recommendation as either 'mandatory' or 'advisory' in the "severity" field.
Guidelines to Follow: Rule # 01: Use 4 spaces for indentation; do not use tabs. Rule # 02: Aim for a maximum line length of 76 columns. Rule # 03: Place the * directly next to the variable name for pointers (e.g., int ptr). Rule # 04: Align variable names where possible and match the style of surrounding code. Rule # 05: Enclose the statement forming the body of control structures (if, else if, else, while, do ... while, for) in braces. Rule # 06: An if (expression) construct must be followed by a compound statement; else must be followed by a compound statement or another if statement. Rule # 07: Terminate all if ... else if constructs with an else clause. Rule # 08: A pointer resulting from arithmetic on a pointer operand must address an element of the same array as that pointer operand. Rule # 09: Do not use the sizeof operator on function parameters declared as "array of type". Rule # 10: Do not use the Standard Library function system from <stdlib.h>. Rule # 11: Follow alignment (<stdalign.h>) and no-return functions (<stdnoreturn.h>) rules. Rule # 12: Do not use type generic expressions (_Generic). Rule # 13: Avoid using obsolescent language features. Rule # 14: Declare all variables at the beginning of a block. Rule # 15: Avoid using global variables; prefer static variables. Rule # 16: Use only approved control structures; avoid goto statements. Rule # 17: Ensure all loops have a fixed upper limit. Rule # 18: Keep functions short and focused on a single task. Rule # 19: Use function prototypes and limit the number of parameters. Rule # 20: Use only standard MISRA-compliant data types. Rule # 21: Avoid dynamic memory allocation (malloc, calloc, free). Rule # 22: Describe the intent, not the action; use full sentences, correct grammar, and spelling. Avoid non-obvious abbreviations. Rule # 23: Use K&R style for bracing; always brace even single-line statements. Rule # 24: Use a single exit point in functions, using goto for error handling. Rule # 25: Wrap non-trivial macros in do {...} while (0). Rule # 26: Avoid magic numbers; use enumerations or constants. Rule # 27: Define bitfield widths for BOOL, enums, and flags to ensure proper alignment. Rule # 28: Use consistent comment styles: Rule # 39: Single-line: / Comment
- Assistantjson
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.