
From: Longfang Liu <liulongfang@huawei.com> Some header files are not used in wd_alg.c and can be deleted. In addition, the traversal linked list pnext may be empty, and judgment needs to be added. Signed-off-by: Longfang Liu <liulongfang@huawei.com> --- include/wd_alg.h | 4 ---- wd_alg.c | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/wd_alg.h b/include/wd_alg.h index 0f446cf..060e874 100644 --- a/include/wd_alg.h +++ b/include/wd_alg.h @@ -9,11 +9,7 @@ #include <fcntl.h> #include <stdbool.h> #include <stdint.h> -#include <stdio.h> -#include <string.h> -#include <syslog.h> #include <unistd.h> -#include <asm/types.h> #ifdef __cplusplus extern "C" { diff --git a/wd_alg.c b/wd_alg.c index ffcadac..d3f47bd 100644 --- a/wd_alg.c +++ b/wd_alg.c @@ -4,9 +4,7 @@ */ #define _GNU_SOURCE -#include <ctype.h> #include <dirent.h> -#include <errno.h> #include <stdbool.h> #include <stdlib.h> #include <string.h> @@ -241,7 +239,8 @@ void wd_enable_drv(struct wd_alg_driver *drv) pnext = pnext->next; } - pnext->available = wd_alg_check_available(drv->calc_type, drv->drv_name); + if (pnext) + pnext->available = wd_alg_check_available(drv->calc_type, drv->drv_name); pthread_mutex_unlock(&mutex); } @@ -260,7 +259,8 @@ void wd_disable_drv(struct wd_alg_driver *drv) pnext = pnext->next; } - pnext->available = false; + if (pnext) + pnext->available = false; pthread_mutex_unlock(&mutex); } -- 2.33.0