@@ -37,7 +37,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
/**
* @file
*
@@ -64,24 +63,24 @@ static int test_ring_basic(shm_ring_t *r)
unsigned i, num_elems;
/* alloc dummy object pointers */
- src = malloc(RING_SIZE*2*sizeof(void *));
- if (src == NULL) {
+ src = malloc(RING_SIZE * 2 * sizeof(void *));
+ if (!src) {
LOG_ERR("failed to allocate test ring src memory\n");
goto fail;
}
- for (i = 0; i < RING_SIZE*2; i++)
+ for (i = 0; i < RING_SIZE * 2; i++)
src[i] = (void *)(unsigned long)i;
cur_src = src;
/* alloc some room for copied objects */
- dst = malloc(RING_SIZE*2*sizeof(void *));
- if (dst == NULL) {
+ dst = malloc(RING_SIZE * 2 * sizeof(void *));
+ if (!dst) {
LOG_ERR("failed to allocate test ring dst memory\n");
goto fail;
}
- memset(dst, 0, RING_SIZE*2*sizeof(void *));
+ memset(dst, 0, RING_SIZE * 2 * sizeof(void *));
cur_dst = dst;
printf("Test SP & SC basic functions\n");
@@ -251,8 +250,8 @@ static int producer_fn(void)
void **src = NULL;
/* alloc dummy object pointers */
- src = malloc(MAX_BULK*2*sizeof(void *));
- if (src == NULL) {
+ src = malloc(MAX_BULK * 2 * sizeof(void *));
+ if (!src) {
LOG_ERR("failed to allocate producer memory.\n");
return -1;
}
@@ -275,8 +274,8 @@ static int consumer_fn(void)
void **src = NULL;
/* alloc dummy object pointers */
- src = malloc(MAX_BULK*2*sizeof(void *));
- if (src == NULL) {
+ src = malloc(MAX_BULK * 2 * sizeof(void *));
+ if (!src) {
LOG_ERR("failed to allocate consumer memory.\n");
return -1;
}
@@ -298,7 +297,6 @@ static int consumer_fn(void)
} while (1);
}
-
/*
* Note : make sure that both enqueue and dequeue
* operation starts at same time so to avoid data corruption
@@ -319,6 +317,7 @@ typedef enum {
static void test_ring_stress(stress_type_t type)
{
int thr;
+
thr = odp_thread_id();
switch (type) {
@@ -331,7 +330,7 @@ static void test_ring_stress(stress_type_t type)
break;
case multi_enq_multi_deq:
- if (thr%2 == 0)
+ if (thr % 2 == 0)
producer_fn();
else
consumer_fn();
@@ -417,7 +416,6 @@ static void *test_ring(void *arg)
return parg;
}
-
int main(int argc __attribute__((__unused__)),
char *argv[] __attribute__((__unused__)))
{
@@ -445,9 +443,9 @@ int main(int argc __attribute__((__unused__)),
snprintf(ring_name, sizeof(ring_name), "test_ring_stress");
r_stress = shm_ring_create(ring_name, RING_SIZE,
- 0 /* not used, alignement
- taken care inside func : todo */);
- if (r_stress == NULL) {
+ 0 /* not used, alignement
+ taken care inside func : todo */);
+ if (!r_stress) {
LOG_ERR("ring create failed\n");
goto fail;
}
Fix codestyle errors reported by checkpatch.pl Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- platform/linux-generic/test/ring/ring_test.c | 32 +++++++++++++--------------- 1 file changed, 15 insertions(+), 17 deletions(-)