Skip to content

Commit abf6adb

Browse files
committed
Move values of __fsdev_init parameters inside __fsdev_init
Function __fsdev_init is called at only single place in the whole codebase, therefore the parameters have always the same values. Instead of passing these values as parameters we can define them as variables inside __fsdev_init and remove those parameters from the signature.
1 parent d73126c commit abf6adb

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/OVAL/probes/fsdev.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ is_local_fs(struct mntent *ment)
185185

186186
#endif /* _AIX */
187187

188-
static fsdev_t *__fsdev_init(fsdev_t * lfs, const char **fs, size_t fs_cnt)
188+
static fsdev_t *__fsdev_init(fsdev_t *lfs)
189189
{
190190
int e;
191191
FILE *fp;
@@ -194,6 +194,9 @@ static fsdev_t *__fsdev_init(fsdev_t * lfs, const char **fs, size_t fs_cnt)
194194
struct mntent *ment;
195195
struct stat st;
196196

197+
const char **fs = NULL;
198+
size_t fs_cnt = 0;
199+
197200
fp = setmntent(_PATH_MOUNTED, "r");
198201
if (fp == NULL) {
199202
e = errno;
@@ -239,12 +242,15 @@ static fsdev_t *__fsdev_init(fsdev_t * lfs, const char **fs, size_t fs_cnt)
239242
return (lfs);
240243
}
241244
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
242-
static fsdev_t *__fsdev_init(fsdev_t * lfs, const char **fs, size_t fs_cnt)
245+
static fsdev_t *__fsdev_init(fsdev_t *lfs)
243246
{
244247
struct statfs *mntbuf = NULL;
245248
struct stat st;
246249
int i;
247250

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

@@ -276,7 +282,7 @@ static fsdev_t *__fsdev_init(fsdev_t * lfs, const char **fs, size_t fs_cnt)
276282
#define DEVID_ARRAY_SIZE 16
277283
#define DEVID_ARRAY_ADD 8
278284

279-
static fsdev_t *__fsdev_init(fsdev_t * lfs, const char **fs, size_t fs_cnt)
285+
static fsdev_t *__fsdev_init(fsdev_t *lfs)
280286
{
281287
int e;
282288
FILE *fp;
@@ -285,6 +291,9 @@ static fsdev_t *__fsdev_init(fsdev_t * lfs, const char **fs, size_t fs_cnt)
285291
struct mnttab mentbuf;
286292
struct stat st;
287293

294+
const char **fs = NULL;
295+
size_t fs_cnt = 0;
296+
288297
fp = fopen(MNTTAB, "r");
289298
if (fp == NULL) {
290299
e = errno;
@@ -345,16 +354,14 @@ static fsdev_t *__fsdev_init(fsdev_t * lfs, const char **fs, size_t fs_cnt)
345354

346355
fsdev_t *fsdev_init()
347356
{
348-
const char **fs = NULL;
349-
size_t fs_cnt = 0;
350357
fsdev_t *lfs;
351358

352359
lfs = malloc(sizeof(fsdev_t));
353360

354361
if (lfs == NULL)
355362
return (NULL);
356363

357-
if (__fsdev_init(lfs, fs, fs_cnt) == NULL)
364+
if (__fsdev_init(lfs) == NULL)
358365
return (NULL);
359366

360367
if (lfs->ids != NULL && lfs->cnt > 1)

0 commit comments

Comments
 (0)