Skip to content

Commit 82fee23

Browse files
committed
Remove dead code
Variable `fs` is defined as NULL, therefore the `else` part condition of condition `if(fs == NULL)` is never executed, so we can remove it. Also, variables `fs` and `fs_cnt` are used only it this never executed piece of code, therefore we can remove them as well.
1 parent abf6adb commit 82fee23

File tree

1 file changed

+13
-50
lines changed

1 file changed

+13
-50
lines changed

src/OVAL/probes/fsdev.c

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,6 @@ static fsdev_t *__fsdev_init(fsdev_t *lfs)
194194
struct mntent *ment;
195195
struct stat st;
196196

197-
const char **fs = NULL;
198-
size_t fs_cnt = 0;
199-
200197
fp = setmntent(_PATH_MOUNTED, "r");
201198
if (fp == NULL) {
202199
e = errno;
@@ -219,12 +216,8 @@ static fsdev_t *__fsdev_init(fsdev_t *lfs)
219216
i = 0;
220217

221218
while ((ment = getmntent(fp)) != NULL) {
222-
if (fs == NULL) {
223-
if (!is_local_fs(ment))
224-
continue;
225-
} else if (!match_fs(ment->mnt_type, fs, fs_cnt)) {
226-
continue;
227-
}
219+
if (!is_local_fs(ment))
220+
continue;
228221
if (stat(ment->mnt_dir, &st) != 0)
229222
continue;
230223
if (i >= lfs->cnt) {
@@ -248,26 +241,14 @@ static fsdev_t *__fsdev_init(fsdev_t *lfs)
248241
struct stat st;
249242
int i;
250243

251-
const char **fs = NULL;
252-
size_t fs_cnt = 0;
253-
254244
lfs->cnt = getmntinfo(&mntbuf, (fs == NULL ? MNT_LOCAL : 0) | MNT_NOWAIT);
255245
lfs->ids = malloc(sizeof(dev_t) * lfs->cnt);
256246

257-
if (fs == NULL) {
258-
for (i = 0; i < lfs->cnt; ++i) {
259-
if (stat(mntbuf[i].f_mntonname, &st) != 0)
260-
continue;
261-
262-
memcpy(&(lfs->ids[i]), &st.st_dev, sizeof(dev_t));
263-
}
264-
} else {
265-
for (i = 0; i < lfs->cnt; ++i) {
266-
if (!match_fs(mntbuf[i].f_fstypename, fs, fs_cnt))
267-
continue;
247+
for (i = 0; i < lfs->cnt; ++i) {
248+
if (stat(mntbuf[i].f_mntonname, &st) != 0)
249+
continue;
268250

269-
memcpy(&(lfs->ids[i]), &st.st_dev, sizeof(dev_t));
270-
}
251+
memcpy(&(lfs->ids[i]), &st.st_dev, sizeof(dev_t));
271252
}
272253

273254
if (i != lfs->cnt) {
@@ -291,9 +272,6 @@ static fsdev_t *__fsdev_init(fsdev_t *lfs)
291272
struct mnttab mentbuf;
292273
struct stat st;
293274

294-
const char **fs = NULL;
295-
size_t fs_cnt = 0;
296-
297275
fp = fopen(MNTTAB, "r");
298276
if (fp == NULL) {
299277
e = errno;
@@ -315,31 +293,16 @@ static fsdev_t *__fsdev_init(fsdev_t *lfs)
315293
lfs->cnt = DEVID_ARRAY_SIZE;
316294
i = 0;
317295

318-
if (fs == NULL) {
319-
while ((getmntent(fp, &mentbuf)) == 0) {
320-
/* TODO: Is this check reliable? */
321-
if (stat (mentbuf.mnt_special, &st) == 0 && (st.st_mode & S_IFCHR)) {
296+
while ((getmntent(fp, &mentbuf)) == 0) {
297+
/* TODO: Is this check reliable? */
298+
if (stat(mentbuf.mnt_special, &st) == 0 && (st.st_mode & S_IFCHR)) {
322299

323-
if (i >= lfs->cnt) {
324-
lfs->cnt += DEVID_ARRAY_ADD;
325-
lfs->ids = realloc(lfs->ids, sizeof(dev_t) * lfs->cnt);
326-
}
327-
328-
memcpy(&(lfs->ids[i++]), &st.st_dev, sizeof(dev_t));
300+
if (i >= lfs->cnt) {
301+
lfs->cnt += DEVID_ARRAY_ADD;
302+
lfs->ids = realloc(lfs->ids, sizeof(dev_t) * lfs->cnt);
329303
}
330-
}
331-
} else {
332-
while ((getmntent(fp, &mentbuf)) == 0) {
333304

334-
if (match_fs(mentbuf.mnt_fstype, fs, fs_cnt)) {
335-
336-
if (i >= lfs->cnt) {
337-
lfs->cnt += DEVID_ARRAY_ADD;
338-
lfs->ids = realloc(lfs->ids, sizeof(dev_t) * lfs->cnt);
339-
}
340-
341-
memcpy(&(lfs->ids[i++]), &st.st_dev, sizeof(dev_t));
342-
}
305+
memcpy(&(lfs->ids[i++]), &st.st_dev, sizeof(dev_t));
343306
}
344307
}
345308

0 commit comments

Comments
 (0)