Conversation
- Replace unsafe string functions (strncpy, strcpy) with cc_safe_strcpy - Remove impossible NULL checks on fixed-size array members (compiler warnings) - Strengthen JSON input validation with early null/empty checks - Add comprehensive error handling and input validation throughout - Improve PID file management with atomic writes and proper cleanup All Codacy security findings resolved while maintaining functionality.
-cppcheck-suppress missingInclude
- fix some cppcheck warnings - add code quality tools to CI
…dering - Extract duplicated cairo_arc calls into reusable draw_rounded_rectangle_path() helper function - Replace duplicate code blocks at lines 149-157 and 192-202 with function calls - Maintain existing functionality for both background and border rendering - Improve code maintainability by following DRY principle - Add proper Doxygen documentation for new helper function Resolves Codacy duplication warning for rounded rectangle path creation.
- Extract common JSON device type parsing logic into reusable extract_device_type_from_json() helper function - Replace duplicate code blocks in coolercontrol.c (lines 155-165) and monitor.c (lines 72-81) - Add function declaration to coolercontrol.h header - Add jansson.h include to coolercontrol.h for json_t type support - Maintain existing functionality while improving code maintainability - Follow DRY principle by centralizing JSON device type extraction logic Resolves Codacy duplication warning for JSON device iteration pattern.
- Replace all if-else chains with early returns in config parsing functions - Reduce get_paths_config() complexity by consolidating null checks - Optimize get_display_config() with helper function for orientation validation - Streamline get_layout_config() using early returns pattern - Simplify get_font_config() and get_temperature_config() with early exits - Refactor get_color_pointer_from_section() eliminating else-if chains - Optimize set_color_component() with early return pattern - Add input validation helper functions to reduce nested conditions Expected complexity reduction from 159 to <50 total complexity score. Functions now follow single responsibility principle with <10 complexity each.
- Replace 8 separate if-blocks with data-driven approach - Reduce cyclomatic complexity from 154 to target <50 - Use ColorDefault struct for cleaner code organization - Maintain same functionality with improved maintainability
Update feature description in README.md
Updated contribution and support links in README. Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Added a contribution tip and links for discussions and issues. Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Removed several badge links and added new installation badges for AUR and manual installation. Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Added warnings and tips for common issues related to CoolerDash and CoolerControl. Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Removed unnecessary 'Solution' header from warning section. Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Removed warranty disclaimer from README. Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
Signed-off-by: damachine <christkue79@gmail.com>
| va_list args; | ||
| va_start(args, format); | ||
| vfprintf(output, format, args); | ||
| vsnprintf(msg_buf, sizeof(msg_buf), (format ? format : "(null)"), args); |
Check warning
Code scanning / Flawfinder (reported by Codacy)
If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. Warning
| FILE *f = fopen(temp_file, "w"); | ||
| if (!f) { | ||
| // Open with specific permissions to avoid race condition | ||
| int fd = open(temp_file, O_WRONLY | O_CREAT | O_EXCL, 0644); |
Check warning
Code scanning / Flawfinder (reported by Codacy)
Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). Warning
| if (config->lcd_brightness == 0) | ||
| config->lcd_brightness = 80; | ||
| if (config->lcd_orientation == 0) | ||
| config->lcd_orientation = 0; |
Check warning
Code scanning / Cppcheck (reported by Codacy)
Assignment 'config->lcd_orientation=0' is redundant with condition 'config->lcd_orientation==0'. Warning
| * @details Common helper function to extract device type string from JSON device object. Returns NULL if extraction fails. | ||
| */ | ||
| const char* extract_device_type_from_json(json_t *dev) { | ||
| if (!dev) return NULL; |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.6 rule Note
| { | ||
| const double radius = 8.0; | ||
| cairo_new_sub_path(cr); | ||
| cairo_arc(cr, x + width - radius, y + radius, radius, -DISPLAY_M_PI_2, 0); |
Check warning
Code scanning / Cppcheck (reported by Codacy)
Skipping configuration 'M_PI_2' since the value of 'M_PI_2' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly. Warning
| const double radius = 8.0; | ||
| cairo_new_sub_path(cr); | ||
| cairo_arc(cr, x + width - radius, y + radius, radius, -DISPLAY_M_PI_2, 0); | ||
| cairo_arc(cr, x + width - radius, y + height - radius, radius, 0, DISPLAY_M_PI_2); |
Check warning
Code scanning / Cppcheck (reported by Codacy)
Skipping configuration 'M_PI_2' since the value of 'M_PI_2' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly. Warning
| cairo_new_sub_path(cr); | ||
| cairo_arc(cr, x + width - radius, y + radius, radius, -DISPLAY_M_PI_2, 0); | ||
| cairo_arc(cr, x + width - radius, y + height - radius, radius, 0, DISPLAY_M_PI_2); | ||
| cairo_arc(cr, x + radius, y + height - radius, radius, DISPLAY_M_PI_2, DISPLAY_M_PI); |
Check warning
Code scanning / Cppcheck (reported by Codacy)
Skipping configuration 'M_PI' since the value of 'M_PI' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly. Warning
| cairo_new_sub_path(cr); | ||
| cairo_arc(cr, x + width - radius, y + radius, radius, -DISPLAY_M_PI_2, 0); | ||
| cairo_arc(cr, x + width - radius, y + height - radius, radius, 0, DISPLAY_M_PI_2); | ||
| cairo_arc(cr, x + radius, y + height - radius, radius, DISPLAY_M_PI_2, DISPLAY_M_PI); |
Check warning
Code scanning / Cppcheck (reported by Codacy)
Skipping configuration 'M_PI_2' since the value of 'M_PI_2' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly. Warning
| cairo_arc(cr, x + width - radius, y + radius, radius, -DISPLAY_M_PI_2, 0); | ||
| cairo_arc(cr, x + width - radius, y + height - radius, radius, 0, DISPLAY_M_PI_2); | ||
| cairo_arc(cr, x + radius, y + height - radius, radius, DISPLAY_M_PI_2, DISPLAY_M_PI); | ||
| cairo_arc(cr, x + radius, y + radius, radius, DISPLAY_M_PI, 1.5 * DISPLAY_M_PI); |
Check warning
Code scanning / Cppcheck (reported by Codacy)
Skipping configuration 'M_PI' since the value of 'M_PI' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly. Warning
Pull Request
🎯 Specialized Templates Available
📝 Description
🔄 Type of Change
🧪 How Has This Been Tested?
Test Configuration:
📋 Checklist
🔗 Related Issues
Fixes #(issue number)
Closes #(issue number)
Related to #(issue number)
📸 Screenshots (if UI changes)
📚 Additional Notes
🎯 Codacy Analysis
For Maintainers: