Content-Type: multipart/mixed; boundary="===============4868044293448562344==" MIME-Version: 1.0 From: ramesh.thomas at intel.com Subject: [Accel-config] [PATCH v1] accel-config: Fix static code analysis issues Date: Fri, 04 Dec 2020 06:10:42 -0500 Message-ID: <20201204111042.309062-1-ramesh.thomas@intel.com> To: accel-config@lists.01.org List-ID: --===============4868044293448562344== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ramesh Thomas Fixed bugs found in static code analysis Signed-off-by: Ramesh Thomas --- accfg/lib/libaccfg.c | 10 ++++++---- accfg/list.c | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c index cd9da42..3b53be3 100644 --- a/accfg/lib/libaccfg.c +++ b/accfg/lib/libaccfg.c @@ -529,7 +529,7 @@ static void *add_wq(void *parent, int id, const char *w= q_base, { struct accfg_wq *wq; struct accfg_device *device =3D parent; - struct accfg_group *group =3D device->group; + struct accfg_group *group; struct accfg_ctx *ctx; char *path; char *wq_base_string; @@ -540,6 +540,7 @@ static void *add_wq(void *parent, int id, const char *w= q_base, if (!device) return NULL; = + group =3D device->group; ctx =3D accfg_device_get_ctx(device); dfd =3D open(wq_base, O_PATH); if (dfd < 0) @@ -615,7 +616,6 @@ err_read: free(wq->wq_buf); free(wq->wq_path); err_wq: - close(dfd); free(wq); free(path); return NULL; @@ -715,7 +715,7 @@ static void *add_engine(void *parent, int id, const cha= r *engine_base, struct accfg_engine *engine; struct accfg_device *device =3D parent; struct accfg_ctx *ctx; - struct accfg_group *group =3D device->group; + struct accfg_group *group; char *path; char *engine_base_string; int dfd; @@ -724,6 +724,7 @@ static void *add_engine(void *parent, int id, const cha= r *engine_base, if (!device) return NULL; = + group =3D device->group; ctx =3D accfg_device_get_ctx(device); dfd =3D open(engine_base, O_PATH); if (dfd < 0) @@ -1109,12 +1110,13 @@ ACCFG_EXPORT int accfg_device_get_clients(struct ac= cfg_device *device) ACCFG_EXPORT int accfg_device_set_token_limit(struct accfg_device *dev, in= t val) { struct accfg_ctx *ctx; - char *path =3D dev->device_buf; + char *path; char buf[SYSFS_ATTR_SIZE]; = if (!dev) return -EINVAL; = + path =3D dev->device_buf; ctx =3D accfg_device_get_ctx(dev); = if (sprintf(path, "%s/token_limit", dev->device_path) >=3D diff --git a/accfg/list.c b/accfg/list.c index c22da41..2234e65 100644 --- a/accfg/list.c +++ b/accfg/list.c @@ -56,8 +56,7 @@ static struct json_object *group_to_json(struct accfg_gro= up *group, struct json_object *jobj =3D NULL; struct accfg_device *dev =3D NULL; = - if (group) - dev =3D accfg_group_get_device(group); + dev =3D accfg_group_get_device(group); = if (!jgroup) return NULL; -- = 2.26.2 --===============4868044293448562344==--