mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
Fix bugs listed by clang's static analyzer
A few pedantic changes and unused variables (1-4), and genuine bugs (5, 6). The reports with the corresponding files and lines numbers are as follows. 1. backend/libinput/tablet_pad.c@31,44,57 "Allocator sizeof operand mismatch" "Result of 'calloc' is converted to a pointer of type 'unsigned int', which is incompatible with sizeof operand type 'int'" 2. types/tablet_v2/wlr_tablet_v2_pad.c@371 "Allocator sizeof operand mismatch" "Result of 'calloc' is converted to a pointer of type 'uint32_t', which is incompatible with sizeof operand type 'int'" 3. types/wlr_cursor.c@335 "Dead initialization" "Value stored to 'dx'/'dy' during its initialization is never read" 4. rootston/xdg_shell.c@510 "Dead initialization" "Value stored to 'desktop' during its initialization is never read" 5. types/tablet_v2/wlr_tablet_v2_pad.c@475 "Dereference of null pointer" "Access to field 'strips' results in a dereference of a null pointer (loaded from field 'current_client')" The boolean logic was incorrect (c.f. the check in the following function). 6. examples/idle.c@163,174,182 "Uninitialized argument value" "1st function call argument is an uninitialized value" If close_timeout != 0, but simulate_activity_timeout >= close_timeout, the program would segfault at pthread_cancel(t1).
This commit is contained in:
parent
2f48453718
commit
8589ae19de
5 changed files with 22 additions and 17 deletions
|
|
@ -152,14 +152,20 @@ int main(int argc, char *argv[]) {
|
|||
.display = display,
|
||||
};
|
||||
|
||||
if (simulate_activity_timeout != 0 && simulate_activity_timeout < close_timeout) {
|
||||
bool create_t1 = (simulate_activity_timeout != 0) &&
|
||||
(simulate_activity_timeout < close_timeout);
|
||||
|
||||
if (create_t1) {
|
||||
if (pthread_create(&t1, NULL, &simulate_activity, (void *)&arg) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (close_timeout != 0) {
|
||||
|
||||
bool create_t2 = (close_timeout != 0);
|
||||
|
||||
if (create_t2) {
|
||||
if (pthread_create(&t2, NULL, &close_program, (void *)&arg) != 0) {
|
||||
if (simulate_activity_timeout != 0) {
|
||||
if (create_t1) {
|
||||
pthread_cancel(t1);
|
||||
}
|
||||
return -1;
|
||||
|
|
@ -170,18 +176,19 @@ int main(int argc, char *argv[]) {
|
|||
fprintf(stdout, "waiting\n");
|
||||
|
||||
if (pthread_create(&t3, NULL, &main_loop, (void *)display) != 0) {
|
||||
if (simulate_activity_timeout != 0) {
|
||||
if (create_t1) {
|
||||
pthread_cancel(t1);
|
||||
}
|
||||
if (close_timeout != 0 ) {
|
||||
if (create_t2) {
|
||||
pthread_cancel(t2);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (simulate_activity_timeout != 0) {
|
||||
if (create_t1) {
|
||||
pthread_join(t1, NULL);
|
||||
}
|
||||
if (close_timeout != 0) {
|
||||
if (create_t2) {
|
||||
pthread_join(t2, NULL);
|
||||
}
|
||||
pthread_cancel(t3);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue