centos 7
obsolete weakness #274

1

Weakness Breakdown


Definition:

An obsolete weakness occurs when someone uses deprecated or obsolete functions when building a system. As a programming language evolves, some functions occasionally become obsolete.

Warning code(s):

This C routine is considered obsolete.

File Name:

libqb-1.0.1/tests/check_util.c

Context:

The highlighted line of code below is the trigger point of this particular Centos 7 obsolete weakness.

 #include "os_base.h"

#include "check_common.h"

#include <qb/qbdefs.h>
#include <qb/qbutil.h>
#include <qb/qblog.h>

#define assert_int_between(_c, _lower, _upper) \
_ck_assert_int(_c, >=, _lower); \
_ck_assert_int(_c, <=, _upper);


START_TEST(test_check_overwrite)
{
	uint64_t res;
	uint32_t last;
	qb_util_stopwatch_t *sw = qb_util_stopwatch_create();

	qb_util_stopwatch_split_ctl(sw, 5, QB_UTIL_SW_OVERWRITE);

	res = qb_util_stopwatch_split(sw);
	assert_int_between(res, 0, 100);

	usleep(10000);
	res = qb_util_stopwatch_split(sw);
	assert_int_between(res, 9000, 11000);

	usleep(20000);
	res = qb_util_stopwatch_split(sw);
	assert_int_between(res, 19000, 21000);

	usleep(30000);
	res = qb_util_stopwatch_split(sw);
	assert_int_between(res, 29000, 31000);

	usleep(40000);
	res = qb_util_stopwatch_split(sw);
	assert_int_between(res, 39000, 41000);

	/*
	 * window should be 100000 (40000 + 30000 + 20000 + 10000) usec
	 */
	last = qb_util_stopwatch_split_last(sw);
	res = qb_util_stopwatch_time_split_get(sw, last, last - 4);
	assert_int_between(res, 95000, 105000);

	usleep(50000);
	res = qb_util_stopwatch_split(sw);
	assert_int_between(res, 49000, 52000); 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.