Message ID | 1396284500-18327-1-git-send-email-maxim.uvarov@linaro.org |
---|---|
State | Accepted |
Headers | show |
Hi, Some of these line removals make the code less readable. Especially around locks, and the empty line before if clause thing we talked already. On Monday, 31 March 2014 19:48:20 UTC+3, Maxim Uvarov wrote: > Remove not needed empty lines and minor style clean up. > > Signed-off-by: Maxim Uvarov <maxim....@linaro.org <javascript:>> > --- > .../include/odp_buffer_pool_internal.h | 1 - > platform/linux-generic/include/odp_internal.h | 7 ------ > platform/linux-generic/include/odp_packet_socket.h | 2 -- > .../linux-generic/include/odp_queue_internal.h | 1 - > .../linux-generic/include/odp_schedule_internal.h | 2 -- > platform/linux-generic/include/odp_spin_internal.h | 2 -- > platform/linux-generic/source/odp_buffer.c | 11 --------- > platform/linux-generic/source/odp_buffer_pool.c | 27 > ++++------------------ > platform/linux-generic/source/odp_coremask.c | 4 +--- > platform/linux-generic/source/odp_linux.c | 7 ------ > platform/linux-generic/source/odp_packet.c | 3 --- > platform/linux-generic/source/odp_packet_flags.c | 5 ++-- > platform/linux-generic/source/odp_queue.c | 13 ----------- > platform/linux-generic/source/odp_rwlock.c | 2 -- > platform/linux-generic/source/odp_shared_memory.c | 13 ----------- > platform/linux-generic/source/odp_spinlock.c | 3 --- > platform/linux-generic/source/odp_system_info.c | 9 -------- > platform/linux-generic/source/odp_thread.c | 9 +------- > platform/linux-generic/source/odp_timer.c | 12 ---------- > 19 files changed, 8 insertions(+), 125 deletions(-) > > diff --git a/platform/linux-generic/include/odp_buffer_pool_internal.h > b/platform/linux-generic/include/odp_buffer_pool_internal.h > index 380de36..381482f 100644 > --- a/platform/linux-generic/include/odp_buffer_pool_internal.h > +++ b/platform/linux-generic/include/odp_buffer_pool_internal.h > @@ -51,7 +51,6 @@ struct pool_entry_s { > uint64_t free_bufs; > char name[ODP_BUFFER_POOL_NAME_LEN]; > > - > odp_buffer_pool_t pool ODP_ALIGNED_CACHE; > uintptr_t buf_base; > size_t buf_size; > diff --git a/platform/linux-generic/include/odp_internal.h > b/platform/linux-generic/include/odp_internal.h > index ff34b5e..fb3be79 100644 > --- a/platform/linux-generic/include/odp_internal.h > +++ b/platform/linux-generic/include/odp_internal.h > @@ -19,18 +19,14 @@ extern "C" { > #endif > > > - > int odp_system_info_init(void); > > - > void odp_thread_init_global(void); > void odp_thread_init_local(int thr_id); > > - > int odp_shm_init_global(void); > int odp_shm_init_local(void); > > - > int odp_buffer_pool_init_global(void); > > int odp_pktio_init_global(void); > @@ -38,14 +34,11 @@ int odp_pktio_init_local(void); > > int odp_queue_init_global(void); > > - > int odp_schedule_init_global(void); > int odp_schedule_init_local(void); > > - > int odp_timer_init_global(void); > > - > #ifdef __cplusplus > } > #endif > diff --git a/platform/linux-generic/include/odp_packet_socket.h > b/platform/linux-generic/include/odp_packet_socket.h > index fe216bb..4dea649 100644 > --- a/platform/linux-generic/include/odp_packet_socket.h > +++ b/platform/linux-generic/include/odp_packet_socket.h > @@ -46,8 +46,6 @@ > /** Max transmit (Tx) burst size*/ > #define ODP_PACKET_SOCKET_MAX_BURST_TX 32 > > - > - > #if (ODP_PACKET_SOCKET_MODE == ODP_PACKET_SOCKET_BASIC) || \ > (ODP_PACKET_SOCKET_MODE == ODP_PACKET_SOCKET_MMSG) > > diff --git a/platform/linux-generic/include/odp_queue_internal.h > b/platform/linux-generic/include/odp_queue_internal.h > index fede56a..8b6c517 100644 > --- a/platform/linux-generic/include/odp_queue_internal.h > +++ b/platform/linux-generic/include/odp_queue_internal.h > @@ -118,4 +118,3 @@ static inline queue_entry_t > *queue_to_qentry(odp_queue_t handle) > #endif > > #endif > - > diff --git a/platform/linux-generic/include/odp_schedule_internal.h > b/platform/linux-generic/include/odp_schedule_internal.h > index b0135c5..7b943bd 100644 > --- a/platform/linux-generic/include/odp_schedule_internal.h > +++ b/platform/linux-generic/include/odp_schedule_internal.h > @@ -29,5 +29,3 @@ void odp_schedule_queue(odp_queue_t queue, int prio); > #endif > > #endif > - > - > diff --git a/platform/linux-generic/include/odp_spin_internal.h > b/platform/linux-generic/include/odp_spin_internal.h > index e70ccf1..1061e52 100644 > --- a/platform/linux-generic/include/odp_spin_internal.h > +++ b/platform/linux-generic/include/odp_spin_internal.h > @@ -60,8 +60,6 @@ static inline void odp_spin(void) > } > > > - > - > #ifdef __cplusplus > } > #endif > diff --git a/platform/linux-generic/source/odp_buffer.c > b/platform/linux-generic/source/odp_buffer.c > index f5b02fd..f506d35 100644 > --- a/platform/linux-generic/source/odp_buffer.c > +++ b/platform/linux-generic/source/odp_buffer.c > @@ -4,7 +4,6 @@ > * SPDX-License-Identifier: BSD-3-Clause > */ > > - > #include <odp_buffer.h> > #include <odp_buffer_internal.h> > #include <odp_buffer_pool_internal.h> > @@ -13,10 +12,6 @@ > #include <stdio.h> > > > - > - > - > - > void *odp_buffer_addr(odp_buffer_t buf) > { > odp_buffer_hdr_t *hdr = odp_buf_to_hdr(buf); > @@ -105,7 +100,6 @@ int odp_buffer_snprint(char *str, size_t n, > odp_buffer_t buf) > } > > > - > void odp_buffer_print(odp_buffer_t buf) > { > int max_len = 512; > @@ -117,8 +111,3 @@ void odp_buffer_print(odp_buffer_t buf) > > printf("\n%s\n", str); > } > - > - > - > - > - > diff --git a/platform/linux-generic/source/odp_buffer_pool.c > b/platform/linux-generic/source/odp_buffer_pool.c > index fecdb18..90214ba 100644 > --- a/platform/linux-generic/source/odp_buffer_pool.c > +++ b/platform/linux-generic/source/odp_buffer_pool.c > @@ -93,7 +93,6 @@ int odp_buffer_pool_init_global(void) > > memset(pool_tbl, 0, sizeof(pool_table_t)); > > - > for (i = 0; i < ODP_CONFIG_BUFFER_POOLS; i++) { > /* init locks */ > pool_entry_t *pool = &pool_tbl->pool[i]; > @@ -108,7 +107,6 @@ int odp_buffer_pool_init_global(void) > ODP_DBG(" pool_entry_t size %zu\n", sizeof(pool_entry_t)); > ODP_DBG(" odp_buffer_hdr_t size %zu\n", > sizeof(odp_buffer_hdr_t)); > ODP_DBG("\n"); > - > return 0; > } > > @@ -118,7 +116,6 @@ static odp_buffer_hdr_t *index_to_hdr(pool_entry_t > *pool, uint32_t index) > odp_buffer_hdr_t *hdr; > > hdr = (odp_buffer_hdr_t *)(pool->s.buf_base + index * > pool->s.buf_size); > - > return hdr; > } > > @@ -139,7 +136,6 @@ static uint32_t rem_buf_index(odp_buffer_chunk_hdr_t > *chunk_hdr) > i = chunk_hdr->chunk.num_bufs - 1; > index = chunk_hdr->chunk.buf_index[i]; > chunk_hdr->chunk.num_bufs--; > - > return index; > } > > @@ -150,7 +146,6 @@ static odp_buffer_chunk_hdr_t *next_chunk(pool_entry_t > *pool, > uint32_t index; > > index = chunk_hdr->chunk.buf_index[ODP_BUFS_PER_CHUNK-1]; > - > if (index == NULL_INDEX) > return NULL; > else > @@ -163,19 +158,16 @@ static odp_buffer_chunk_hdr_t > *rem_chunk(pool_entry_t *pool) > odp_buffer_chunk_hdr_t *chunk_hdr; > > chunk_hdr = pool->s.head; > - > if (chunk_hdr == NULL) { > /* Pool is empty */ > return NULL; > } > > pool->s.head = next_chunk(pool, chunk_hdr); > - > pool->s.free_bufs -= ODP_BUFS_PER_CHUNK; > > /* unlink */ > rem_buf_index(chunk_hdr); > - > return chunk_hdr; > } > > @@ -185,12 +177,10 @@ static void add_chunk(pool_entry_t *pool, > odp_buffer_chunk_hdr_t *chunk_hdr) > if (pool->s.head) { > /* link pool head to the chunk */ > add_buf_index(chunk_hdr, pool->s.head->buf_hdr.index); > - } else { > Is this OK for checkpatch. I think it requires that else has brackets if the preceding if clause has those. Minor thing anyway... > + } else > add_buf_index(chunk_hdr, NULL_INDEX); > - } > > pool->s.head = chunk_hdr; > - > pool->s.free_bufs += ODP_BUFS_PER_CHUNK; > } > > @@ -255,24 +245,22 @@ static void link_bufs(pool_entry_t *pool) > uintptr_t pool_base; > int buf_type; > > - > buf_type = pool->s.buf_type; > payload_size = pool->s.payload_size; > payload_align = pool->s.payload_align; > pool_size = pool->s.pool_size; > pool_base = (uintptr_t) pool->s.pool_base_addr; > > - if (buf_type == ODP_BUFFER_TYPE_RAW) { > + if (buf_type == ODP_BUFFER_TYPE_RAW) > hdr_size = sizeof(odp_buffer_hdr_t); > - } else if (buf_type == ODP_BUFFER_TYPE_PACKET) { > + else if (buf_type == ODP_BUFFER_TYPE_PACKET) > hdr_size = sizeof(odp_packet_hdr_t); > - } else { > + else { > ODP_ERR("odp_buffer_pool_create: Bad type %i\n", > buf_type); > exit(0); > } > > - > /* Chunk must fit into buffer payload.*/ > min_size = sizeof(odp_buffer_chunk_hdr_t) - hdr_size; > if (payload_size < min_size) > @@ -291,7 +279,6 @@ static void link_bufs(pool_entry_t *pool) > else > size = payload_align + offset; > > - > /* First buffer */ > buf_base = ODP_ALIGN_ROUNDUP(pool_base + offset, payload_align) > - offset; > @@ -382,17 +369,14 @@ odp_buffer_pool_t odp_buffer_pool_lookup(const char > *name) > pool = get_pool_entry(i); > > LOCK(&pool->s.lock); > - New line here is intentional, so that LOCK stands out from the code. It's pretty important to notice if we are inside a locked region or not. So please do not remove these lines. > > if (strcmp(name, pool->s.name) == 0) { > /* found it */ > UNLOCK(&pool->s.lock); > return i; > } > - > Same thing with unlock. -Petri > UNLOCK(&pool->s.lock); > } > > - > return ODP_BUFFER_POOL_INVALID; > } > > @@ -432,8 +416,6 @@ odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t > pool_id) > handle = hdr->handle; > } > > - > - > return handle.u32; > } > > @@ -450,7 +432,6 @@ void odp_buffer_free(odp_buffer_t buf) > pool = get_pool_entry(pool_id); > chunk_hdr = local_chunk[pool_id]; > > - > if (chunk_hdr && chunk_hdr->chunk.num_bufs == ODP_BUFS_PER_CHUNK > - 1) { > /* Current chunk is full. Push back to the pool */ > LOCK(&pool->s.lock); > diff --git a/platform/linux-generic/source/odp_coremask.c > b/platform/linux-generic/source/odp_coremask.c > index 22be78f..c55eb72 100644 > --- a/platform/linux-generic/source/odp_coremask.c > +++ b/platform/linux-generic/source/odp_coremask.c > @@ -50,10 +50,8 @@ void odp_coremask_from_u64(const uint64_t *u64, int > num, odp_coremask_t *mask) > num = ODP_COREMASK_SIZE_U64; > } > > - for (i = 0; i < num; i++) { > - /* */ > + for (i = 0; i < num; i++) > mask->_u64[0] |= u64[i]; > - } > } > > void odp_coremask_set(int core, odp_coremask_t *mask) > diff --git a/platform/linux-generic/source/odp_linux.c > b/platform/linux-generic/source/odp_linux.c > index 42b7d89..6adeb3f 100644 > --- a/platform/linux-generic/source/odp_linux.c > +++ b/platform/linux-generic/source/odp_linux.c > @@ -28,7 +28,6 @@ typedef struct { > } odp_start_args_t; > > > - > static void *odp_run_start_routine(void *arg) > { > odp_start_args_t *start_args = arg; > @@ -40,8 +39,6 @@ static void *odp_run_start_routine(void *arg) > } > > > - > - > void odp_linux_pthread_create(odp_linux_pthread_t *thread_tbl, int num, > int first_core, void *(*start_routine) (void *), void > *arg) > { > @@ -58,7 +55,6 @@ void odp_linux_pthread_create(odp_linux_pthread_t > *thread_tbl, int num, > > memset(thread_tbl, 0, num * sizeof(odp_linux_pthread_t)); > > - > for (i = 0; i < num; i++) { > pthread_attr_init(&thread_tbl[i].attr); > > @@ -83,7 +79,6 @@ void odp_linux_pthread_create(odp_linux_pthread_t > *thread_tbl, int num, > } > > > - > void odp_linux_pthread_join(odp_linux_pthread_t *thread_tbl, int num) > { > int i; > @@ -93,5 +88,3 @@ void odp_linux_pthread_join(odp_linux_pthread_t > *thread_tbl, int num) > pthread_join(thread_tbl[i].thread, NULL); > } > } > - > - > diff --git a/platform/linux-generic/source/odp_packet.c > b/platform/linux-generic/source/odp_packet.c > index 5f07374..8af5169 100644 > --- a/platform/linux-generic/source/odp_packet.c > +++ b/platform/linux-generic/source/odp_packet.c > @@ -87,7 +87,6 @@ void odp_packet_set_l2_offset(odp_packet_t pkt, size_t > offset) > odp_packet_hdr(pkt)->l2_offset = offset; > } > > - > uint8_t *odp_packet_l3(odp_packet_t pkt) > { > const size_t offset = odp_packet_l3_offset(pkt); > @@ -108,7 +107,6 @@ void odp_packet_set_l3_offset(odp_packet_t pkt, size_t > offset) > odp_packet_hdr(pkt)->l3_offset = offset; > } > > - > uint8_t *odp_packet_l4(odp_packet_t pkt) > { > const size_t offset = odp_packet_l4_offset(pkt); > @@ -330,4 +328,3 @@ void odp_packet_print(odp_packet_t pkt) > > printf("\n%s\n", str); > } > - > diff --git a/platform/linux-generic/source/odp_packet_flags.c > b/platform/linux-generic/source/odp_packet_flags.c > index 0fd0aa9..992b94b 100644 > --- a/platform/linux-generic/source/odp_packet_flags.c > +++ b/platform/linux-generic/source/odp_packet_flags.c > @@ -4,8 +4,8 @@ > * SPDX-License-Identifier: BSD-3-Clause > */ > > - #include <odp_packet_flags.h> > - #include <odp_packet_internal.h> > +#include <odp_packet_flags.h> > +#include <odp_packet_internal.h> > > > int odp_packet_error(odp_packet_t pkt) > @@ -113,4 +113,3 @@ void odp_packet_outflag_l4_chksum(odp_packet_t pkt) > { > odp_packet_hdr(pkt)->output_flags.l4_chksum = 1; > } > - > diff --git a/platform/linux-generic/source/odp_queue.c > b/platform/linux-generic/source/odp_queue.c > index 648c18e..49bc766 100644 > --- a/platform/linux-generic/source/odp_queue.c > +++ b/platform/linux-generic/source/odp_queue.c > @@ -146,7 +146,6 @@ odp_queue_t odp_queue_create(const char *name, > odp_queue_type_t type, > continue; > > LOCK(&queue->s.lock); > - > if (queue->s.status == QUEUE_STATUS_FREE) { > queue_init(queue, name, type, param); > > @@ -157,28 +156,23 @@ odp_queue_t odp_queue_create(const char *name, > odp_queue_type_t type, > queue->s.status = QUEUE_STATUS_READY; > > handle = queue->s.handle; > - > UNLOCK(&queue->s.lock); > break; > } > - > UNLOCK(&queue->s.lock); > } > > - > if (handle != ODP_QUEUE_INVALID && > (type == ODP_QUEUE_TYPE_SCHED || type == > ODP_QUEUE_TYPE_PKTIN)) { > odp_buffer_t buf; > > buf = odp_schedule_buffer_alloc(handle); > - > if (buf == ODP_BUFFER_INVALID) { > ODP_ERR("queue_init: sched buf alloc failed\n"); > return ODP_QUEUE_INVALID; > } > > queue->s.sched_buf = buf; > - > odp_schedule_mask_set(handle, queue->s.param.sched.prio); > } > > @@ -215,13 +209,11 @@ odp_queue_t odp_queue_lookup(const char *name) > continue; > > LOCK(&queue->s.lock); > - > if (strcmp(name, queue->s.name) == 0) { > /* found it */ > UNLOCK(&queue->s.lock); > return queue->s.handle; > } > - > UNLOCK(&queue->s.lock); > } > > @@ -234,7 +226,6 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t > *buf_hdr) > int sched = 0; > > LOCK(&queue->s.lock); > - > if (queue->s.head == NULL) { > /* Empty queue */ > queue->s.head = buf_hdr; > @@ -250,7 +241,6 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t > *buf_hdr) > queue->s.status = QUEUE_STATUS_SCHED; > sched = 1; /* retval: schedule queue */ > } > - > UNLOCK(&queue->s.lock); > > /* Add queue to scheduling */ > @@ -274,7 +264,6 @@ int queue_enq_multi(queue_entry_t *queue, > odp_buffer_hdr_t *buf_hdr[], int num) > buf_hdr[num-1]->next = NULL; > > LOCK(&queue->s.lock); > - > /* Empty queue */ > if (queue->s.head == NULL) > queue->s.head = buf_hdr[0]; > @@ -287,7 +276,6 @@ int queue_enq_multi(queue_entry_t *queue, > odp_buffer_hdr_t *buf_hdr[], int num) > queue->s.status = QUEUE_STATUS_SCHED; > sched = 1; /* retval: schedule queue */ > } > - > UNLOCK(&queue->s.lock); > > /* Add queue to scheduling */ > @@ -411,7 +399,6 @@ int odp_queue_deq_multi(odp_queue_t handle, > odp_buffer_t buf[], int num) > } > > > - > odp_buffer_t odp_queue_deq(odp_queue_t handle) > { > queue_entry_t *queue; > diff --git a/platform/linux-generic/source/odp_rwlock.c > b/platform/linux-generic/source/odp_rwlock.c > index 19c58e1..c2b34e3 100644 > --- a/platform/linux-generic/source/odp_rwlock.c > +++ b/platform/linux-generic/source/odp_rwlock.c > @@ -59,5 +59,3 @@ void odp_rwlock_write_unlock(odp_rwlock_t *rwlock) > { > odp_atomic_inc_u32((odp_atomic_u32_t *)(intptr_t)&rwlock->cnt); > } > - > - > diff --git a/platform/linux-generic/source/odp_shared_memory.c > b/platform/linux-generic/source/odp_shared_memory.c > index c607c99..8288b46 100644 > --- a/platform/linux-generic/source/odp_shared_memory.c > +++ b/platform/linux-generic/source/odp_shared_memory.c > @@ -4,7 +4,6 @@ > * SPDX-License-Identifier: BSD-3-Clause > */ > > - > #include <odp_shared_memory.h> > #include <odp_internal.h> > #include <odp_spinlock.h> > @@ -50,7 +49,6 @@ typedef struct { > static odp_shm_table_t *odp_shm_tbl; > > > - > int odp_shm_init_global(void) > { > void *addr; > @@ -172,7 +170,6 @@ void *odp_shm_reserve(const char *name, uint64_t size, > uint64_t align) > } > > > - > void *odp_shm_lookup(const char *name) > { > int i; > @@ -194,7 +191,6 @@ void *odp_shm_lookup(const char *name) > } > > > - > void odp_shm_print_all(void) > { > int i; > @@ -226,12 +222,3 @@ void odp_shm_print_all(void) > > printf("\n"); > } > - > - > - > - > - > - > - > - > - > diff --git a/platform/linux-generic/source/odp_spinlock.c > b/platform/linux-generic/source/odp_spinlock.c > index da98278..4eba015 100644 > --- a/platform/linux-generic/source/odp_spinlock.c > +++ b/platform/linux-generic/source/odp_spinlock.c > @@ -38,6 +38,3 @@ int odp_spinlock_is_locked(odp_spinlock_t *spinlock) > { > return spinlock->lock != 0; > } > - > - > - > diff --git a/platform/linux-generic/source/odp_system_info.c > b/platform/linux-generic/source/odp_system_info.c > index 17617b0..f78b746 100644 > --- a/platform/linux-generic/source/odp_system_info.c > +++ b/platform/linux-generic/source/odp_system_info.c > @@ -52,7 +52,6 @@ static int sysconf_core_count(void) > long ret; > > ret = sysconf(_SC_NPROCESSORS_CONF); > - > if (ret < 0) > return 0; > > @@ -72,7 +71,6 @@ static int systemcpu_cache_line_size(void) > int size = 0; > > file = fopen(CACHE_LNSZ_FILE, "rt"); > - > if (file == NULL) { > /* File not found */ > return 0; > @@ -96,7 +94,6 @@ static int huge_page_size(void) > int size = 0; > > dir = opendir(HUGE_PAGE_DIR); > - > if (dir == NULL) { > ODP_ERR("%s not found\n", HUGE_PAGE_DIR); > return 0; > @@ -137,7 +134,6 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t > *sysinfo) > while (fgets(str, sizeof(str), file) != NULL && count > 0) { > if (!mhz) { > pos = strstr(str, "cpu MHz"); > - > if (pos) { > sscanf(pos, "cpu MHz : %lf", &mhz); > count--; > @@ -146,7 +142,6 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t > *sysinfo) > > if (!model) { > pos = strstr(str, "model name"); > - > if (pos) { > int len; > pos = strchr(str, ':'); > @@ -293,7 +288,6 @@ static int systemcpu(odp_system_info_t *sysinfo) > int ret; > > ret = sysconf_core_count(); > - > if (ret == 0) { > ODP_ERR("sysconf_core_count failed.\n"); > return -1; > @@ -303,7 +297,6 @@ static int systemcpu(odp_system_info_t *sysinfo) > > > ret = systemcpu_cache_line_size(); > - > if (ret == 0) { > ODP_ERR("systemcpu_cache_line_size failed.\n"); > return -1; > @@ -333,7 +326,6 @@ static int systemcpu(odp_system_info_t *sysinfo) > int ret; > > ret = sysconf_core_count(); > - > if (ret == 0) { > ODP_ERR("sysconf_core_count failed.\n"); > return -1; > @@ -364,7 +356,6 @@ int odp_system_info_init(void) > odp_system_info.page_size = ODP_PAGE_SIZE; > > file = fopen("/proc/cpuinfo", "rt"); > - > if (file == NULL) { > ODP_ERR("Failed to open /proc/cpuinfo\n"); > return -1; > diff --git a/platform/linux-generic/source/odp_thread.c > b/platform/linux-generic/source/odp_thread.c > index 4bee2aa..eaa480e 100644 > --- a/platform/linux-generic/source/odp_thread.c > +++ b/platform/linux-generic/source/odp_thread.c > @@ -4,7 +4,6 @@ > * SPDX-License-Identifier: BSD-3-Clause > */ > > - > #include <odp_thread.h> > #include <odp_internal.h> > #include <odp_atomic.h> > @@ -14,8 +13,6 @@ > #include <stdio.h> > > > - > - > typedef struct { > int thr_id; > int phys_core; > @@ -23,8 +20,6 @@ typedef struct { > } odp_thread_tbl_t; > > > - > - > /* Globals */ > static odp_thread_tbl_t odp_thread_tbl[ODP_CONFIG_MAX_THREADS]; > static odp_atomic_int_t num_threads; > @@ -48,7 +43,7 @@ void odp_thread_init_local(int thr_id) > > int odp_thread_create(int phys_core) > { > - int id = -1; > + int id; > > id = odp_atomic_fetch_add_int(&num_threads, 1); > > @@ -71,5 +66,3 @@ int odp_thread_core(void) > { > return odp_this_thread->phys_core; > } > - > - > diff --git a/platform/linux-generic/source/odp_timer.c > b/platform/linux-generic/source/odp_timer.c > index 824ec0e..001b505 100644 > --- a/platform/linux-generic/source/odp_timer.c > +++ b/platform/linux-generic/source/odp_timer.c > @@ -168,12 +168,10 @@ int odp_timer_init_global(void) > > timer_init(); > > - > return 0; > } > > > - > odp_timer_t odp_timer_create(const char *name, odp_buffer_pool_t pool, > uint64_t resolution, uint64_t min_tmo, > uint64_t max_tmo) > @@ -185,7 +183,6 @@ odp_timer_t odp_timer_create(const char *name, > odp_buffer_pool_t pool, > return ODP_TIMER_INVALID; > > id = odp_atomic_fetch_inc_int(&odp_timer.num_timers); > - > if (id >= NUM_TIMERS) > return ODP_TIMER_INVALID; > > @@ -213,14 +210,12 @@ odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t > timer, uint64_t tmo_tick, > id = timer - 1; > > cur_tick = odp_timer.timer[id].cur_tick; > - > if (tmo_tick <= cur_tick) { > ODP_DBG("timeout too close\n"); > return ODP_TIMER_TMO_INVALID; > } > > tick = tmo_tick - cur_tick; > - > if (tick > MAX_TICKS) { > ODP_DBG("timeout too far\n"); > return ODP_TIMER_TMO_INVALID; > @@ -229,7 +224,6 @@ odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t > timer, uint64_t tmo_tick, > tick = (cur_tick + tick) % MAX_TICKS; > > tmo_buf = odp_buffer_alloc(odp_timer.timer[id].pool); > - > if (tmo_buf == ODP_BUFFER_INVALID) { > ODP_DBG("alloc failed\n"); > return ODP_TIMER_TMO_INVALID; > @@ -254,13 +248,11 @@ odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t > timer, uint64_t tmo_tick, > } > > > - > uint64_t odp_timer_tick_to_ns(odp_timer_t timer, uint64_t ticks) > { > uint32_t id; > > id = timer - 1; > - > return ticks * odp_timer.timer[id].resolution_ns; > } > > @@ -270,7 +262,6 @@ uint64_t odp_timer_ns_to_tick(odp_timer_t timer, > uint64_t ns) > uint32_t id; > > id = timer - 1; > - > return ns / odp_timer.timer[id].resolution_ns; > } > > @@ -280,7 +271,6 @@ uint64_t odp_timer_resolution(odp_timer_t timer) > uint32_t id; > > id = timer - 1; > - > return odp_timer.timer[id].resolution_ns; > } > > @@ -290,7 +280,6 @@ uint64_t odp_timer_maximum_tmo(odp_timer_t timer) > uint32_t id; > > id = timer - 1; > - > return odp_timer.timer[id].max_ticks; > } > > @@ -300,6 +289,5 @@ uint64_t odp_timer_current_tick(odp_timer_t timer) > uint32_t id; > > id = timer - 1; > - > return odp_timer.timer[id].cur_tick; > } > -- > 1.8.5.1.163.gd7aced9 > >
I agree with Petri. Judicious use of blank lines to separate functions can improve readability. As long as the blank line is just a newline character and not spaces checkpatch doesn't seem to have any problems with it so I don't see why we need to go beyond that rule. Bill On Tue, Apr 1, 2014 at 7:47 AM, Petri Savolainen < petri.savolainen@linaro.org> wrote: > Hi, > > Some of these line removals make the code less readable. Especially around > locks, and the empty line before if clause thing we talked already. > > > > On Monday, 31 March 2014 19:48:20 UTC+3, Maxim Uvarov wrote: > >> Remove not needed empty lines and minor style clean up. >> >> Signed-off-by: Maxim Uvarov <maxim....@linaro.org> >> --- >> .../include/odp_buffer_pool_internal.h | 1 - >> platform/linux-generic/include/odp_internal.h | 7 ------ >> platform/linux-generic/include/odp_packet_socket.h | 2 -- >> .../linux-generic/include/odp_queue_internal.h | 1 - >> .../linux-generic/include/odp_schedule_internal.h | 2 -- >> platform/linux-generic/include/odp_spin_internal.h | 2 -- >> platform/linux-generic/source/odp_buffer.c | 11 --------- >> platform/linux-generic/source/odp_buffer_pool.c | 27 >> ++++------------------ >> platform/linux-generic/source/odp_coremask.c | 4 +--- >> platform/linux-generic/source/odp_linux.c | 7 ------ >> platform/linux-generic/source/odp_packet.c | 3 --- >> platform/linux-generic/source/odp_packet_flags.c | 5 ++-- >> platform/linux-generic/source/odp_queue.c | 13 ----------- >> platform/linux-generic/source/odp_rwlock.c | 2 -- >> platform/linux-generic/source/odp_shared_memory.c | 13 ----------- >> platform/linux-generic/source/odp_spinlock.c | 3 --- >> platform/linux-generic/source/odp_system_info.c | 9 -------- >> platform/linux-generic/source/odp_thread.c | 9 +------- >> platform/linux-generic/source/odp_timer.c | 12 ---------- >> 19 files changed, 8 insertions(+), 125 deletions(-) >> >> diff --git a/platform/linux-generic/include/odp_buffer_pool_internal.h >> b/platform/linux-generic/include/odp_buffer_pool_internal.h >> index 380de36..381482f 100644 >> --- a/platform/linux-generic/include/odp_buffer_pool_internal.h >> +++ b/platform/linux-generic/include/odp_buffer_pool_internal.h >> @@ -51,7 +51,6 @@ struct pool_entry_s { >> uint64_t free_bufs; >> char name[ODP_BUFFER_POOL_NAME_LEN]; >> >> - >> odp_buffer_pool_t pool ODP_ALIGNED_CACHE; >> uintptr_t buf_base; >> size_t buf_size; >> diff --git a/platform/linux-generic/include/odp_internal.h >> b/platform/linux-generic/include/odp_internal.h >> index ff34b5e..fb3be79 100644 >> --- a/platform/linux-generic/include/odp_internal.h >> +++ b/platform/linux-generic/include/odp_internal.h >> @@ -19,18 +19,14 @@ extern "C" { >> #endif >> >> >> - >> int odp_system_info_init(void); >> >> - >> void odp_thread_init_global(void); >> void odp_thread_init_local(int thr_id); >> >> - >> int odp_shm_init_global(void); >> int odp_shm_init_local(void); >> >> - >> int odp_buffer_pool_init_global(void); >> >> int odp_pktio_init_global(void); >> @@ -38,14 +34,11 @@ int odp_pktio_init_local(void); >> >> int odp_queue_init_global(void); >> >> - >> int odp_schedule_init_global(void); >> int odp_schedule_init_local(void); >> >> - >> int odp_timer_init_global(void); >> >> - >> #ifdef __cplusplus >> } >> #endif >> diff --git a/platform/linux-generic/include/odp_packet_socket.h >> b/platform/linux-generic/include/odp_packet_socket.h >> index fe216bb..4dea649 100644 >> --- a/platform/linux-generic/include/odp_packet_socket.h >> +++ b/platform/linux-generic/include/odp_packet_socket.h >> @@ -46,8 +46,6 @@ >> /** Max transmit (Tx) burst size*/ >> #define ODP_PACKET_SOCKET_MAX_BURST_TX 32 >> >> - >> - >> #if (ODP_PACKET_SOCKET_MODE == ODP_PACKET_SOCKET_BASIC) || \ >> (ODP_PACKET_SOCKET_MODE == ODP_PACKET_SOCKET_MMSG) >> >> diff --git a/platform/linux-generic/include/odp_queue_internal.h >> b/platform/linux-generic/include/odp_queue_internal.h >> index fede56a..8b6c517 100644 >> --- a/platform/linux-generic/include/odp_queue_internal.h >> +++ b/platform/linux-generic/include/odp_queue_internal.h >> @@ -118,4 +118,3 @@ static inline queue_entry_t >> *queue_to_qentry(odp_queue_t handle) >> #endif >> >> #endif >> - >> diff --git a/platform/linux-generic/include/odp_schedule_internal.h >> b/platform/linux-generic/include/odp_schedule_internal.h >> index b0135c5..7b943bd 100644 >> --- a/platform/linux-generic/include/odp_schedule_internal.h >> +++ b/platform/linux-generic/include/odp_schedule_internal.h >> @@ -29,5 +29,3 @@ void odp_schedule_queue(odp_queue_t queue, int prio); >> #endif >> >> #endif >> - >> - >> diff --git a/platform/linux-generic/include/odp_spin_internal.h >> b/platform/linux-generic/include/odp_spin_internal.h >> index e70ccf1..1061e52 100644 >> --- a/platform/linux-generic/include/odp_spin_internal.h >> +++ b/platform/linux-generic/include/odp_spin_internal.h >> @@ -60,8 +60,6 @@ static inline void odp_spin(void) >> } >> >> >> - >> - >> #ifdef __cplusplus >> } >> #endif >> diff --git a/platform/linux-generic/source/odp_buffer.c >> b/platform/linux-generic/source/odp_buffer.c >> index f5b02fd..f506d35 100644 >> --- a/platform/linux-generic/source/odp_buffer.c >> +++ b/platform/linux-generic/source/odp_buffer.c >> @@ -4,7 +4,6 @@ >> * SPDX-License-Identifier: BSD-3-Clause >> */ >> >> - >> #include <odp_buffer.h> >> #include <odp_buffer_internal.h> >> #include <odp_buffer_pool_internal.h> >> @@ -13,10 +12,6 @@ >> #include <stdio.h> >> >> >> - >> - >> - >> - >> void *odp_buffer_addr(odp_buffer_t buf) >> { >> odp_buffer_hdr_t *hdr = odp_buf_to_hdr(buf); >> @@ -105,7 +100,6 @@ int odp_buffer_snprint(char *str, size_t n, >> odp_buffer_t buf) >> } >> >> >> - >> void odp_buffer_print(odp_buffer_t buf) >> { >> int max_len = 512; >> @@ -117,8 +111,3 @@ void odp_buffer_print(odp_buffer_t buf) >> >> printf("\n%s\n", str); >> } >> - >> - >> - >> - >> - >> diff --git a/platform/linux-generic/source/odp_buffer_pool.c >> b/platform/linux-generic/source/odp_buffer_pool.c >> index fecdb18..90214ba 100644 >> --- a/platform/linux-generic/source/odp_buffer_pool.c >> +++ b/platform/linux-generic/source/odp_buffer_pool.c >> @@ -93,7 +93,6 @@ int odp_buffer_pool_init_global(void) >> >> memset(pool_tbl, 0, sizeof(pool_table_t)); >> >> - >> for (i = 0; i < ODP_CONFIG_BUFFER_POOLS; i++) { >> /* init locks */ >> pool_entry_t *pool = &pool_tbl->pool[i]; >> @@ -108,7 +107,6 @@ int odp_buffer_pool_init_global(void) >> ODP_DBG(" pool_entry_t size %zu\n", sizeof(pool_entry_t)); >> ODP_DBG(" odp_buffer_hdr_t size %zu\n", >> sizeof(odp_buffer_hdr_t)); >> ODP_DBG("\n"); >> - >> return 0; >> } >> >> @@ -118,7 +116,6 @@ static odp_buffer_hdr_t *index_to_hdr(pool_entry_t >> *pool, uint32_t index) >> odp_buffer_hdr_t *hdr; >> >> hdr = (odp_buffer_hdr_t *)(pool->s.buf_base + index * >> pool->s.buf_size); >> - >> return hdr; >> } >> >> @@ -139,7 +136,6 @@ static uint32_t rem_buf_index(odp_buffer_chunk_hdr_t >> *chunk_hdr) >> i = chunk_hdr->chunk.num_bufs - 1; >> index = chunk_hdr->chunk.buf_index[i]; >> chunk_hdr->chunk.num_bufs--; >> - >> return index; >> } >> >> @@ -150,7 +146,6 @@ static odp_buffer_chunk_hdr_t >> *next_chunk(pool_entry_t *pool, >> uint32_t index; >> >> index = chunk_hdr->chunk.buf_index[ODP_BUFS_PER_CHUNK-1]; >> - >> if (index == NULL_INDEX) >> return NULL; >> else >> @@ -163,19 +158,16 @@ static odp_buffer_chunk_hdr_t >> *rem_chunk(pool_entry_t *pool) >> odp_buffer_chunk_hdr_t *chunk_hdr; >> >> chunk_hdr = pool->s.head; >> - >> if (chunk_hdr == NULL) { >> /* Pool is empty */ >> return NULL; >> } >> >> pool->s.head = next_chunk(pool, chunk_hdr); >> - >> pool->s.free_bufs -= ODP_BUFS_PER_CHUNK; >> >> /* unlink */ >> rem_buf_index(chunk_hdr); >> - >> return chunk_hdr; >> } >> >> @@ -185,12 +177,10 @@ static void add_chunk(pool_entry_t *pool, >> odp_buffer_chunk_hdr_t *chunk_hdr) >> if (pool->s.head) { >> /* link pool head to the chunk */ >> add_buf_index(chunk_hdr, pool->s.head->buf_hdr.index); >> - } else { >> > > Is this OK for checkpatch. I think it requires that else has brackets if > the preceding if clause has those. Minor thing anyway... > > >> + } else >> add_buf_index(chunk_hdr, NULL_INDEX); >> - } >> >> pool->s.head = chunk_hdr; >> - >> pool->s.free_bufs += ODP_BUFS_PER_CHUNK; >> } >> >> @@ -255,24 +245,22 @@ static void link_bufs(pool_entry_t *pool) >> uintptr_t pool_base; >> int buf_type; >> >> - >> buf_type = pool->s.buf_type; >> payload_size = pool->s.payload_size; >> payload_align = pool->s.payload_align; >> pool_size = pool->s.pool_size; >> pool_base = (uintptr_t) pool->s.pool_base_addr; >> >> - if (buf_type == ODP_BUFFER_TYPE_RAW) { >> + if (buf_type == ODP_BUFFER_TYPE_RAW) >> hdr_size = sizeof(odp_buffer_hdr_t); >> - } else if (buf_type == ODP_BUFFER_TYPE_PACKET) { >> + else if (buf_type == ODP_BUFFER_TYPE_PACKET) >> hdr_size = sizeof(odp_packet_hdr_t); >> - } else { >> + else { >> ODP_ERR("odp_buffer_pool_create: Bad type %i\n", >> buf_type); >> exit(0); >> } >> >> - >> /* Chunk must fit into buffer payload.*/ >> min_size = sizeof(odp_buffer_chunk_hdr_t) - hdr_size; >> if (payload_size < min_size) >> @@ -291,7 +279,6 @@ static void link_bufs(pool_entry_t *pool) >> else >> size = payload_align + offset; >> >> - >> /* First buffer */ >> buf_base = ODP_ALIGN_ROUNDUP(pool_base + offset, payload_align) >> - offset; >> @@ -382,17 +369,14 @@ odp_buffer_pool_t odp_buffer_pool_lookup(const char >> *name) >> pool = get_pool_entry(i); >> >> LOCK(&pool->s.lock); >> - > > New line here is intentional, so that LOCK stands out from the code. It's > pretty important to notice if we are inside a locked region or not. So > please do not remove these lines. > > >> >> if (strcmp(name, pool->s.name) == 0) { >> /* found it */ >> UNLOCK(&pool->s.lock); >> return i; >> } >> - >> > > Same thing with unlock. > > -Petri > > >> UNLOCK(&pool->s.lock); >> } >> >> - >> return ODP_BUFFER_POOL_INVALID; >> } >> >> @@ -432,8 +416,6 @@ odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t >> pool_id) >> handle = hdr->handle; >> } >> >> - >> - >> return handle.u32; >> } >> >> @@ -450,7 +432,6 @@ void odp_buffer_free(odp_buffer_t buf) >> pool = get_pool_entry(pool_id); >> chunk_hdr = local_chunk[pool_id]; >> >> - >> if (chunk_hdr && chunk_hdr->chunk.num_bufs == ODP_BUFS_PER_CHUNK >> - 1) { >> /* Current chunk is full. Push back to the pool */ >> LOCK(&pool->s.lock); >> diff --git a/platform/linux-generic/source/odp_coremask.c >> b/platform/linux-generic/source/odp_coremask.c >> index 22be78f..c55eb72 100644 >> --- a/platform/linux-generic/source/odp_coremask.c >> +++ b/platform/linux-generic/source/odp_coremask.c >> @@ -50,10 +50,8 @@ void odp_coremask_from_u64(const uint64_t *u64, int >> num, odp_coremask_t *mask) >> num = ODP_COREMASK_SIZE_U64; >> } >> >> - for (i = 0; i < num; i++) { >> - /* */ >> + for (i = 0; i < num; i++) >> mask->_u64[0] |= u64[i]; >> - } >> } >> >> void odp_coremask_set(int core, odp_coremask_t *mask) >> diff --git a/platform/linux-generic/source/odp_linux.c >> b/platform/linux-generic/source/odp_linux.c >> index 42b7d89..6adeb3f 100644 >> --- a/platform/linux-generic/source/odp_linux.c >> +++ b/platform/linux-generic/source/odp_linux.c >> @@ -28,7 +28,6 @@ typedef struct { >> } odp_start_args_t; >> >> >> - >> static void *odp_run_start_routine(void *arg) >> { >> odp_start_args_t *start_args = arg; >> @@ -40,8 +39,6 @@ static void *odp_run_start_routine(void *arg) >> } >> >> >> - >> - >> void odp_linux_pthread_create(odp_linux_pthread_t *thread_tbl, int num, >> int first_core, void *(*start_routine) (void *), void >> *arg) >> { >> @@ -58,7 +55,6 @@ void odp_linux_pthread_create(odp_linux_pthread_t >> *thread_tbl, int num, >> >> memset(thread_tbl, 0, num * sizeof(odp_linux_pthread_t)); >> >> - >> for (i = 0; i < num; i++) { >> pthread_attr_init(&thread_tbl[i].attr); >> >> @@ -83,7 +79,6 @@ void odp_linux_pthread_create(odp_linux_pthread_t >> *thread_tbl, int num, >> } >> >> >> - >> void odp_linux_pthread_join(odp_linux_pthread_t *thread_tbl, int num) >> { >> int i; >> @@ -93,5 +88,3 @@ void odp_linux_pthread_join(odp_linux_pthread_t >> *thread_tbl, int num) >> pthread_join(thread_tbl[i].thread, NULL); >> } >> } >> - >> - >> diff --git a/platform/linux-generic/source/odp_packet.c >> b/platform/linux-generic/source/odp_packet.c >> index 5f07374..8af5169 100644 >> --- a/platform/linux-generic/source/odp_packet.c >> +++ b/platform/linux-generic/source/odp_packet.c >> @@ -87,7 +87,6 @@ void odp_packet_set_l2_offset(odp_packet_t pkt, size_t >> offset) >> odp_packet_hdr(pkt)->l2_offset = offset; >> } >> >> - >> uint8_t *odp_packet_l3(odp_packet_t pkt) >> { >> const size_t offset = odp_packet_l3_offset(pkt); >> @@ -108,7 +107,6 @@ void odp_packet_set_l3_offset(odp_packet_t pkt, >> size_t offset) >> odp_packet_hdr(pkt)->l3_offset = offset; >> } >> >> - >> uint8_t *odp_packet_l4(odp_packet_t pkt) >> { >> const size_t offset = odp_packet_l4_offset(pkt); >> @@ -330,4 +328,3 @@ void odp_packet_print(odp_packet_t pkt) >> >> printf("\n%s\n", str); >> } >> - >> diff --git a/platform/linux-generic/source/odp_packet_flags.c >> b/platform/linux-generic/source/odp_packet_flags.c >> index 0fd0aa9..992b94b 100644 >> --- a/platform/linux-generic/source/odp_packet_flags.c >> +++ b/platform/linux-generic/source/odp_packet_flags.c >> @@ -4,8 +4,8 @@ >> * SPDX-License-Identifier: BSD-3-Clause >> */ >> >> - #include <odp_packet_flags.h> >> - #include <odp_packet_internal.h> >> +#include <odp_packet_flags.h> >> +#include <odp_packet_internal.h> >> >> >> int odp_packet_error(odp_packet_t pkt) >> @@ -113,4 +113,3 @@ void odp_packet_outflag_l4_chksum(odp_packet_t pkt) >> { >> odp_packet_hdr(pkt)->output_flags.l4_chksum = 1; >> } >> - >> diff --git a/platform/linux-generic/source/odp_queue.c >> b/platform/linux-generic/source/odp_queue.c >> index 648c18e..49bc766 100644 >> --- a/platform/linux-generic/source/odp_queue.c >> +++ b/platform/linux-generic/source/odp_queue.c >> @@ -146,7 +146,6 @@ odp_queue_t odp_queue_create(const char *name, >> odp_queue_type_t type, >> continue; >> >> LOCK(&queue->s.lock); >> - >> if (queue->s.status == QUEUE_STATUS_FREE) { >> queue_init(queue, name, type, param); >> >> @@ -157,28 +156,23 @@ odp_queue_t odp_queue_create(const char *name, >> odp_queue_type_t type, >> queue->s.status = QUEUE_STATUS_READY; >> >> handle = queue->s.handle; >> - >> UNLOCK(&queue->s.lock); >> break; >> } >> - >> UNLOCK(&queue->s.lock); >> } >> >> - >> if (handle != ODP_QUEUE_INVALID && >> (type == ODP_QUEUE_TYPE_SCHED || type == >> ODP_QUEUE_TYPE_PKTIN)) { >> odp_buffer_t buf; >> >> buf = odp_schedule_buffer_alloc(handle); >> - >> if (buf == ODP_BUFFER_INVALID) { >> ODP_ERR("queue_init: sched buf alloc >> failed\n"); >> return ODP_QUEUE_INVALID; >> } >> >> queue->s.sched_buf = buf; >> - >> odp_schedule_mask_set(handle, >> queue->s.param.sched.prio); >> } >> >> @@ -215,13 +209,11 @@ odp_queue_t odp_queue_lookup(const char *name) >> continue; >> >> LOCK(&queue->s.lock); >> - >> if (strcmp(name, queue->s.name) == 0) { >> /* found it */ >> UNLOCK(&queue->s.lock); >> return queue->s.handle; >> } >> - >> UNLOCK(&queue->s.lock); >> } >> >> @@ -234,7 +226,6 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t >> *buf_hdr) >> int sched = 0; >> >> LOCK(&queue->s.lock); >> - >> if (queue->s.head == NULL) { >> /* Empty queue */ >> queue->s.head = buf_hdr; >> @@ -250,7 +241,6 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t >> *buf_hdr) >> queue->s.status = QUEUE_STATUS_SCHED; >> sched = 1; /* retval: schedule queue */ >> } >> - >> UNLOCK(&queue->s.lock); >> >> /* Add queue to scheduling */ >> @@ -274,7 +264,6 @@ int queue_enq_multi(queue_entry_t *queue, >> odp_buffer_hdr_t *buf_hdr[], int num) >> buf_hdr[num-1]->next = NULL; >> >> LOCK(&queue->s.lock); >> - >> /* Empty queue */ >> if (queue->s.head == NULL) >> queue->s.head = buf_hdr[0]; >> @@ -287,7 +276,6 @@ int queue_enq_multi(queue_entry_t *queue, >> odp_buffer_hdr_t *buf_hdr[], int num) >> queue->s.status = QUEUE_STATUS_SCHED; >> sched = 1; /* retval: schedule queue */ >> } >> - >> UNLOCK(&queue->s.lock); >> >> /* Add queue to scheduling */ >> @@ -411,7 +399,6 @@ int odp_queue_deq_multi(odp_queue_t handle, >> odp_buffer_t buf[], int num) >> } >> >> >> - >> odp_buffer_t odp_queue_deq(odp_queue_t handle) >> { >> queue_entry_t *queue; >> diff --git a/platform/linux-generic/source/odp_rwlock.c >> b/platform/linux-generic/source/odp_rwlock.c >> index 19c58e1..c2b34e3 100644 >> --- a/platform/linux-generic/source/odp_rwlock.c >> +++ b/platform/linux-generic/source/odp_rwlock.c >> @@ -59,5 +59,3 @@ void odp_rwlock_write_unlock(odp_rwlock_t *rwlock) >> { >> odp_atomic_inc_u32((odp_atomic_u32_t *)(intptr_t)&rwlock->cnt); >> } >> - >> - >> diff --git a/platform/linux-generic/source/odp_shared_memory.c >> b/platform/linux-generic/source/odp_shared_memory.c >> index c607c99..8288b46 100644 >> --- a/platform/linux-generic/source/odp_shared_memory.c >> +++ b/platform/linux-generic/source/odp_shared_memory.c >> @@ -4,7 +4,6 @@ >> * SPDX-License-Identifier: BSD-3-Clause >> */ >> >> - >> #include <odp_shared_memory.h> >> #include <odp_internal.h> >> #include <odp_spinlock.h> >> @@ -50,7 +49,6 @@ typedef struct { >> static odp_shm_table_t *odp_shm_tbl; >> >> >> - >> int odp_shm_init_global(void) >> { >> void *addr; >> @@ -172,7 +170,6 @@ void *odp_shm_reserve(const char *name, uint64_t >> size, uint64_t align) >> } >> >> >> - >> void *odp_shm_lookup(const char *name) >> { >> int i; >> @@ -194,7 +191,6 @@ void *odp_shm_lookup(const char *name) >> } >> >> >> - >> void odp_shm_print_all(void) >> { >> int i; >> @@ -226,12 +222,3 @@ void odp_shm_print_all(void) >> >> printf("\n"); >> } >> - >> - >> - >> - >> - >> - >> - >> - >> - >> diff --git a/platform/linux-generic/source/odp_spinlock.c >> b/platform/linux-generic/source/odp_spinlock.c >> index da98278..4eba015 100644 >> --- a/platform/linux-generic/source/odp_spinlock.c >> +++ b/platform/linux-generic/source/odp_spinlock.c >> @@ -38,6 +38,3 @@ int odp_spinlock_is_locked(odp_spinlock_t *spinlock) >> { >> return spinlock->lock != 0; >> } >> - >> - >> - >> diff --git a/platform/linux-generic/source/odp_system_info.c >> b/platform/linux-generic/source/odp_system_info.c >> index 17617b0..f78b746 100644 >> --- a/platform/linux-generic/source/odp_system_info.c >> +++ b/platform/linux-generic/source/odp_system_info.c >> @@ -52,7 +52,6 @@ static int sysconf_core_count(void) >> long ret; >> >> ret = sysconf(_SC_NPROCESSORS_CONF); >> - >> if (ret < 0) >> return 0; >> >> @@ -72,7 +71,6 @@ static int systemcpu_cache_line_size(void) >> int size = 0; >> >> file = fopen(CACHE_LNSZ_FILE, "rt"); >> - >> if (file == NULL) { >> /* File not found */ >> return 0; >> @@ -96,7 +94,6 @@ static int huge_page_size(void) >> int size = 0; >> >> dir = opendir(HUGE_PAGE_DIR); >> - >> if (dir == NULL) { >> ODP_ERR("%s not found\n", HUGE_PAGE_DIR); >> return 0; >> @@ -137,7 +134,6 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t >> *sysinfo) >> while (fgets(str, sizeof(str), file) != NULL && count > 0) { >> if (!mhz) { >> pos = strstr(str, "cpu MHz"); >> - >> if (pos) { >> sscanf(pos, "cpu MHz : %lf", &mhz); >> count--; >> @@ -146,7 +142,6 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t >> *sysinfo) >> >> if (!model) { >> pos = strstr(str, "model name"); >> - >> if (pos) { >> int len; >> pos = strchr(str, ':'); >> @@ -293,7 +288,6 @@ static int systemcpu(odp_system_info_t *sysinfo) >> int ret; >> >> ret = sysconf_core_count(); >> - >> if (ret == 0) { >> ODP_ERR("sysconf_core_count failed.\n"); >> return -1; >> @@ -303,7 +297,6 @@ static int systemcpu(odp_system_info_t *sysinfo) >> >> >> ret = systemcpu_cache_line_size(); >> - >> if (ret == 0) { >> ODP_ERR("systemcpu_cache_line_size failed.\n"); >> return -1; >> @@ -333,7 +326,6 @@ static int systemcpu(odp_system_info_t *sysinfo) >> int ret; >> >> ret = sysconf_core_count(); >> - >> if (ret == 0) { >> ODP_ERR("sysconf_core_count failed.\n"); >> return -1; >> @@ -364,7 +356,6 @@ int odp_system_info_init(void) >> odp_system_info.page_size = ODP_PAGE_SIZE; >> >> file = fopen("/proc/cpuinfo", "rt"); >> - >> if (file == NULL) { >> ODP_ERR("Failed to open /proc/cpuinfo\n"); >> return -1; >> diff --git a/platform/linux-generic/source/odp_thread.c >> b/platform/linux-generic/source/odp_thread.c >> index 4bee2aa..eaa480e 100644 >> --- a/platform/linux-generic/source/odp_thread.c >> +++ b/platform/linux-generic/source/odp_thread.c >> @@ -4,7 +4,6 @@ >> * SPDX-License-Identifier: BSD-3-Clause >> */ >> >> - >> #include <odp_thread.h> >> #include <odp_internal.h> >> #include <odp_atomic.h> >> @@ -14,8 +13,6 @@ >> #include <stdio.h> >> >> >> - >> - >> typedef struct { >> int thr_id; >> int phys_core; >> @@ -23,8 +20,6 @@ typedef struct { >> } odp_thread_tbl_t; >> >> >> - >> - >> /* Globals */ >> static odp_thread_tbl_t odp_thread_tbl[ODP_CONFIG_MAX_THREADS]; >> static odp_atomic_int_t num_threads; >> @@ -48,7 +43,7 @@ void odp_thread_init_local(int thr_id) >> >> int odp_thread_create(int phys_core) >> { >> - int id = -1; >> + int id; >> >> id = odp_atomic_fetch_add_int(&num_threads, 1); >> >> @@ -71,5 +66,3 @@ int odp_thread_core(void) >> { >> return odp_this_thread->phys_core; >> } >> - >> - >> diff --git a/platform/linux-generic/source/odp_timer.c >> b/platform/linux-generic/source/odp_timer.c >> index 824ec0e..001b505 100644 >> --- a/platform/linux-generic/source/odp_timer.c >> +++ b/platform/linux-generic/source/odp_timer.c >> @@ -168,12 +168,10 @@ int odp_timer_init_global(void) >> >> timer_init(); >> >> - >> return 0; >> } >> >> >> - >> odp_timer_t odp_timer_create(const char *name, odp_buffer_pool_t pool, >> uint64_t resolution, uint64_t min_tmo, >> uint64_t max_tmo) >> @@ -185,7 +183,6 @@ odp_timer_t odp_timer_create(const char *name, >> odp_buffer_pool_t pool, >> return ODP_TIMER_INVALID; >> >> id = odp_atomic_fetch_inc_int(&odp_timer.num_timers); >> - >> if (id >= NUM_TIMERS) >> return ODP_TIMER_INVALID; >> >> @@ -213,14 +210,12 @@ odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t >> timer, uint64_t tmo_tick, >> id = timer - 1; >> >> cur_tick = odp_timer.timer[id].cur_tick; >> - >> if (tmo_tick <= cur_tick) { >> ODP_DBG("timeout too close\n"); >> return ODP_TIMER_TMO_INVALID; >> } >> >> tick = tmo_tick - cur_tick; >> - >> if (tick > MAX_TICKS) { >> ODP_DBG("timeout too far\n"); >> return ODP_TIMER_TMO_INVALID; >> @@ -229,7 +224,6 @@ odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t >> timer, uint64_t tmo_tick, >> tick = (cur_tick + tick) % MAX_TICKS; >> >> tmo_buf = odp_buffer_alloc(odp_timer.timer[id].pool); >> - >> if (tmo_buf == ODP_BUFFER_INVALID) { >> ODP_DBG("alloc failed\n"); >> return ODP_TIMER_TMO_INVALID; >> @@ -254,13 +248,11 @@ odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t >> timer, uint64_t tmo_tick, >> } >> >> >> - >> uint64_t odp_timer_tick_to_ns(odp_timer_t timer, uint64_t ticks) >> { >> uint32_t id; >> >> id = timer - 1; >> - >> return ticks * odp_timer.timer[id].resolution_ns; >> } >> >> @@ -270,7 +262,6 @@ uint64_t odp_timer_ns_to_tick(odp_timer_t timer, >> uint64_t ns) >> uint32_t id; >> >> id = timer - 1; >> - >> return ns / odp_timer.timer[id].resolution_ns; >> } >> >> @@ -280,7 +271,6 @@ uint64_t odp_timer_resolution(odp_timer_t timer) >> uint32_t id; >> >> id = timer - 1; >> - >> return odp_timer.timer[id].resolution_ns; >> } >> >> @@ -290,7 +280,6 @@ uint64_t odp_timer_maximum_tmo(odp_timer_t timer) >> uint32_t id; >> >> id = timer - 1; >> - >> return odp_timer.timer[id].max_ticks; >> } >> >> @@ -300,6 +289,5 @@ uint64_t odp_timer_current_tick(odp_timer_t timer) >> uint32_t id; >> >> id = timer - 1; >> - >> return odp_timer.timer[id].cur_tick; >> } >> -- >> 1.8.5.1.163.gd7aced9 >> >> -- > You received this message because you are subscribed to the Google Groups > "LNG ODP Sub-team - lng-odp@linaro.org" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to lng-odp+unsubscribe@linaro.org. > To post to this group, send email to lng-odp@linaro.org. > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/30ab39ee-fe27-4fbd-8ff7-5fc662eca8b5%40linaro.org<https://groups.google.com/a/linaro.org/d/msgid/lng-odp/30ab39ee-fe27-4fbd-8ff7-5fc662eca8b5%40linaro.org?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/a/linaro.org/d/optout. >
Ok. So that I applied thread patch which mainly changes 3 empty lines to 2. And all other style changes will be in separate patch (if they will be needed). Maxim. On 04/01/2014 05:10 PM, Bill Fischofer wrote: > I agree with Petri. Judicious use of blank lines to separate > functions can improve readability. As long as the blank line is just > a newline character and not spaces checkpatch doesn't seem to have any > problems with it so I don't see why we need to go beyond that rule. > > Bill > > > On Tue, Apr 1, 2014 at 7:47 AM, Petri Savolainen > <petri.savolainen@linaro.org <mailto:petri.savolainen@linaro.org>> wrote: > > Hi, > > Some of these line removals make the code less readable. > Especially around locks, and the empty line before if clause thing > we talked already. > > > > On Monday, 31 March 2014 19:48:20 UTC+3, Maxim Uvarov wrote: > > Remove not needed empty lines and minor style clean up. > > Signed-off-by: Maxim Uvarov <maxim....@linaro.org> > --- > .../include/odp_buffer_pool_internal.h | 1 - > platform/linux-generic/include/odp_internal.h | 7 ------ > platform/linux-generic/include/odp_packet_socket.h | 2 -- > .../linux-generic/include/odp_queue_internal.h | 1 - > .../linux-generic/include/odp_schedule_internal.h | 2 -- > platform/linux-generic/include/odp_spin_internal.h | 2 -- > platform/linux-generic/source/odp_buffer.c | 11 --------- > platform/linux-generic/source/odp_buffer_pool.c | 27 > ++++------------------ > platform/linux-generic/source/odp_coremask.c | 4 +--- > platform/linux-generic/source/odp_linux.c | 7 ------ > platform/linux-generic/source/odp_packet.c | 3 --- > platform/linux-generic/source/odp_packet_flags.c | 5 ++-- > platform/linux-generic/source/odp_queue.c | 13 ----------- > platform/linux-generic/source/odp_rwlock.c | 2 -- > platform/linux-generic/source/odp_shared_memory.c | 13 > ----------- > platform/linux-generic/source/odp_spinlock.c | 3 --- > platform/linux-generic/source/odp_system_info.c | 9 -------- > platform/linux-generic/source/odp_thread.c | 9 +------- > platform/linux-generic/source/odp_timer.c | 12 ---------- > 19 files changed, 8 insertions(+), 125 deletions(-) > > diff --git > a/platform/linux-generic/include/odp_buffer_pool_internal.h > b/platform/linux-generic/include/odp_buffer_pool_internal.h > index 380de36..381482f 100644 > --- a/platform/linux-generic/include/odp_buffer_pool_internal.h > +++ b/platform/linux-generic/include/odp_buffer_pool_internal.h > @@ -51,7 +51,6 @@ struct pool_entry_s { > uint64_t free_bufs; > char name[ODP_BUFFER_POOL_NAME_LEN]; > > - > odp_buffer_pool_t pool ODP_ALIGNED_CACHE; > uintptr_t buf_base; > size_t buf_size; > diff --git a/platform/linux-generic/include/odp_internal.h > b/platform/linux-generic/include/odp_internal.h > index ff34b5e..fb3be79 100644 > --- a/platform/linux-generic/include/odp_internal.h > +++ b/platform/linux-generic/include/odp_internal.h > @@ -19,18 +19,14 @@ extern "C" { > #endif > > > - > int odp_system_info_init(void); > > - > void odp_thread_init_global(void); > void odp_thread_init_local(int thr_id); > > - > int odp_shm_init_global(void); > int odp_shm_init_local(void); > > - > int odp_buffer_pool_init_global(void); > > int odp_pktio_init_global(void); > @@ -38,14 +34,11 @@ int odp_pktio_init_local(void); > > int odp_queue_init_global(void); > > - > int odp_schedule_init_global(void); > int odp_schedule_init_local(void); > > - > int odp_timer_init_global(void); > > - > #ifdef __cplusplus > } > #endif > diff --git > a/platform/linux-generic/include/odp_packet_socket.h > b/platform/linux-generic/include/odp_packet_socket.h > index fe216bb..4dea649 100644 > --- a/platform/linux-generic/include/odp_packet_socket.h > +++ b/platform/linux-generic/include/odp_packet_socket.h > @@ -46,8 +46,6 @@ > /** Max transmit (Tx) burst size*/ > #define ODP_PACKET_SOCKET_MAX_BURST_TX 32 > > - > - > #if (ODP_PACKET_SOCKET_MODE == ODP_PACKET_SOCKET_BASIC) || \ > (ODP_PACKET_SOCKET_MODE == ODP_PACKET_SOCKET_MMSG) > > diff --git > a/platform/linux-generic/include/odp_queue_internal.h > b/platform/linux-generic/include/odp_queue_internal.h > index fede56a..8b6c517 100644 > --- a/platform/linux-generic/include/odp_queue_internal.h > +++ b/platform/linux-generic/include/odp_queue_internal.h > @@ -118,4 +118,3 @@ static inline queue_entry_t > *queue_to_qentry(odp_queue_t handle) > #endif > > #endif > - > diff --git > a/platform/linux-generic/include/odp_schedule_internal.h > b/platform/linux-generic/include/odp_schedule_internal.h > index b0135c5..7b943bd 100644 > --- a/platform/linux-generic/include/odp_schedule_internal.h > +++ b/platform/linux-generic/include/odp_schedule_internal.h > @@ -29,5 +29,3 @@ void odp_schedule_queue(odp_queue_t queue, > int prio); > #endif > > #endif > - > - > diff --git > a/platform/linux-generic/include/odp_spin_internal.h > b/platform/linux-generic/include/odp_spin_internal.h > index e70ccf1..1061e52 100644 > --- a/platform/linux-generic/include/odp_spin_internal.h > +++ b/platform/linux-generic/include/odp_spin_internal.h > @@ -60,8 +60,6 @@ static inline void odp_spin(void) > } > > > - > - > #ifdef __cplusplus > } > #endif > diff --git a/platform/linux-generic/source/odp_buffer.c > b/platform/linux-generic/source/odp_buffer.c > index f5b02fd..f506d35 100644 > --- a/platform/linux-generic/source/odp_buffer.c > +++ b/platform/linux-generic/source/odp_buffer.c > @@ -4,7 +4,6 @@ > * SPDX-License-Identifier: BSD-3-Clause > */ > > - > #include <odp_buffer.h> > #include <odp_buffer_internal.h> > #include <odp_buffer_pool_internal.h> > @@ -13,10 +12,6 @@ > #include <stdio.h> > > > - > - > - > - > void *odp_buffer_addr(odp_buffer_t buf) > { > odp_buffer_hdr_t *hdr = odp_buf_to_hdr(buf); > @@ -105,7 +100,6 @@ int odp_buffer_snprint(char *str, size_t > n, odp_buffer_t buf) > } > > > - > void odp_buffer_print(odp_buffer_t buf) > { > int max_len = 512; > @@ -117,8 +111,3 @@ void odp_buffer_print(odp_buffer_t buf) > > printf("\n%s\n", str); > } > - > - > - > - > - > diff --git a/platform/linux-generic/source/odp_buffer_pool.c > b/platform/linux-generic/source/odp_buffer_pool.c > index fecdb18..90214ba 100644 > --- a/platform/linux-generic/source/odp_buffer_pool.c > +++ b/platform/linux-generic/source/odp_buffer_pool.c > @@ -93,7 +93,6 @@ int odp_buffer_pool_init_global(void) > > memset(pool_tbl, 0, sizeof(pool_table_t)); > > - > for (i = 0; i < ODP_CONFIG_BUFFER_POOLS; i++) { > /* init locks */ > pool_entry_t *pool = &pool_tbl->pool[i]; > @@ -108,7 +107,6 @@ int odp_buffer_pool_init_global(void) > ODP_DBG(" pool_entry_t size %zu\n", > sizeof(pool_entry_t)); > ODP_DBG(" odp_buffer_hdr_t size %zu\n", > sizeof(odp_buffer_hdr_t)); > ODP_DBG("\n"); > - > return 0; > } > > @@ -118,7 +116,6 @@ static odp_buffer_hdr_t > *index_to_hdr(pool_entry_t *pool, uint32_t index) > odp_buffer_hdr_t *hdr; > > hdr = (odp_buffer_hdr_t *)(pool->s.buf_base + index * > pool->s.buf_size); > - > return hdr; > } > > @@ -139,7 +136,6 @@ static uint32_t > rem_buf_index(odp_buffer_chunk_hdr_t *chunk_hdr) > i = chunk_hdr->chunk.num_bufs - 1; > index = chunk_hdr->chunk.buf_index[i]; > chunk_hdr->chunk.num_bufs--; > - > return index; > } > > @@ -150,7 +146,6 @@ static odp_buffer_chunk_hdr_t > *next_chunk(pool_entry_t *pool, > uint32_t index; > > index = > chunk_hdr->chunk.buf_index[ODP_BUFS_PER_CHUNK-1]; > - > if (index == NULL_INDEX) > return NULL; > else > @@ -163,19 +158,16 @@ static odp_buffer_chunk_hdr_t > *rem_chunk(pool_entry_t *pool) > odp_buffer_chunk_hdr_t *chunk_hdr; > > chunk_hdr = pool->s.head; > - > if (chunk_hdr == NULL) { > /* Pool is empty */ > return NULL; > } > > pool->s.head = next_chunk(pool, chunk_hdr); > - > pool->s.free_bufs -= ODP_BUFS_PER_CHUNK; > > /* unlink */ > rem_buf_index(chunk_hdr); > - > return chunk_hdr; > } > > @@ -185,12 +177,10 @@ static void add_chunk(pool_entry_t > *pool, odp_buffer_chunk_hdr_t *chunk_hdr) > if (pool->s.head) { > /* link pool head to the chunk */ > add_buf_index(chunk_hdr, > pool->s.head->buf_hdr.index); > - } else { > > > Is this OK for checkpatch. I think it requires that else has > brackets if the preceding if clause has those. Minor thing anyway... > > + } else > add_buf_index(chunk_hdr, NULL_INDEX); > - } > > pool->s.head = chunk_hdr; > - > pool->s.free_bufs += ODP_BUFS_PER_CHUNK; > } > > @@ -255,24 +245,22 @@ static void link_bufs(pool_entry_t *pool) > uintptr_t pool_base; > int buf_type; > > - > buf_type = pool->s.buf_type; > payload_size = pool->s.payload_size; > payload_align = pool->s.payload_align; > pool_size = pool->s.pool_size; > pool_base = (uintptr_t) pool->s.pool_base_addr; > > - if (buf_type == ODP_BUFFER_TYPE_RAW) { > + if (buf_type == ODP_BUFFER_TYPE_RAW) > hdr_size = sizeof(odp_buffer_hdr_t); > - } else if (buf_type == ODP_BUFFER_TYPE_PACKET) { > + else if (buf_type == ODP_BUFFER_TYPE_PACKET) > hdr_size = sizeof(odp_packet_hdr_t); > - } else { > + else { > ODP_ERR("odp_buffer_pool_create: Bad type %i\n", > buf_type); > exit(0); > } > > - > /* Chunk must fit into buffer payload.*/ > min_size = sizeof(odp_buffer_chunk_hdr_t) - hdr_size; > if (payload_size < min_size) > @@ -291,7 +279,6 @@ static void link_bufs(pool_entry_t *pool) > else > size = payload_align + offset; > > - > /* First buffer */ > buf_base = ODP_ALIGN_ROUNDUP(pool_base + offset, > payload_align) > - offset; > @@ -382,17 +369,14 @@ odp_buffer_pool_t > odp_buffer_pool_lookup(const char *name) > pool = get_pool_entry(i); > > LOCK(&pool->s.lock); > - > > New line here is intentional, so that LOCK stands out from the > code. It's pretty important to notice if we are inside a locked > region or not. So please do not remove these lines. > > > if (strcmp(name, pool->s.name > <http://s.name>) == 0) { > /* found it */ > UNLOCK(&pool->s.lock); > return i; > } > - > > > Same thing with unlock. > > -Petri > > UNLOCK(&pool->s.lock); > } > > - > return ODP_BUFFER_POOL_INVALID; > } > > @@ -432,8 +416,6 @@ odp_buffer_t > odp_buffer_alloc(odp_buffer_pool_t pool_id) > handle = hdr->handle; > } > > - > - > return handle.u32; > } > > @@ -450,7 +432,6 @@ void odp_buffer_free(odp_buffer_t buf) > pool = get_pool_entry(pool_id); > chunk_hdr = local_chunk[pool_id]; > > - > if (chunk_hdr && chunk_hdr->chunk.num_bufs == > ODP_BUFS_PER_CHUNK - 1) { > /* Current chunk is full. Push back to the > pool */ > LOCK(&pool->s.lock); > diff --git a/platform/linux-generic/source/odp_coremask.c > b/platform/linux-generic/source/odp_coremask.c > index 22be78f..c55eb72 100644 > --- a/platform/linux-generic/source/odp_coremask.c > +++ b/platform/linux-generic/source/odp_coremask.c > @@ -50,10 +50,8 @@ void odp_coremask_from_u64(const uint64_t > *u64, int num, odp_coremask_t *mask) > num = ODP_COREMASK_SIZE_U64; > } > > - for (i = 0; i < num; i++) { > - /* */ > + for (i = 0; i < num; i++) > mask->_u64[0] |= u64[i]; > - } > } > > void odp_coremask_set(int core, odp_coremask_t *mask) > diff --git a/platform/linux-generic/source/odp_linux.c > b/platform/linux-generic/source/odp_linux.c > index 42b7d89..6adeb3f 100644 > --- a/platform/linux-generic/source/odp_linux.c > +++ b/platform/linux-generic/source/odp_linux.c > @@ -28,7 +28,6 @@ typedef struct { > } odp_start_args_t; > > > - > static void *odp_run_start_routine(void *arg) > { > odp_start_args_t *start_args = arg; > @@ -40,8 +39,6 @@ static void *odp_run_start_routine(void *arg) > } > > > - > - > void odp_linux_pthread_create(odp_linux_pthread_t > *thread_tbl, int num, > int first_core, void *(*start_routine) (void > *), void *arg) > { > @@ -58,7 +55,6 @@ void > odp_linux_pthread_create(odp_linux_pthread_t *thread_tbl, int > num, > > memset(thread_tbl, 0, num * > sizeof(odp_linux_pthread_t)); > > - > for (i = 0; i < num; i++) { > pthread_attr_init(&thread_tbl[i].attr); > > @@ -83,7 +79,6 @@ void > odp_linux_pthread_create(odp_linux_pthread_t *thread_tbl, int > num, > } > > > - > void odp_linux_pthread_join(odp_linux_pthread_t *thread_tbl, > int num) > { > int i; > @@ -93,5 +88,3 @@ void > odp_linux_pthread_join(odp_linux_pthread_t *thread_tbl, int num) > pthread_join(thread_tbl[i].thread, NULL); > } > } > - > - > diff --git a/platform/linux-generic/source/odp_packet.c > b/platform/linux-generic/source/odp_packet.c > index 5f07374..8af5169 100644 > --- a/platform/linux-generic/source/odp_packet.c > +++ b/platform/linux-generic/source/odp_packet.c > @@ -87,7 +87,6 @@ void odp_packet_set_l2_offset(odp_packet_t > pkt, size_t offset) > odp_packet_hdr(pkt)->l2_offset = offset; > } > > - > uint8_t *odp_packet_l3(odp_packet_t pkt) > { > const size_t offset = odp_packet_l3_offset(pkt); > @@ -108,7 +107,6 @@ void odp_packet_set_l3_offset(odp_packet_t > pkt, size_t offset) > odp_packet_hdr(pkt)->l3_offset = offset; > } > > - > uint8_t *odp_packet_l4(odp_packet_t pkt) > { > const size_t offset = odp_packet_l4_offset(pkt); > @@ -330,4 +328,3 @@ void odp_packet_print(odp_packet_t pkt) > > printf("\n%s\n", str); > } > - > diff --git a/platform/linux-generic/source/odp_packet_flags.c > b/platform/linux-generic/source/odp_packet_flags.c > index 0fd0aa9..992b94b 100644 > --- a/platform/linux-generic/source/odp_packet_flags.c > +++ b/platform/linux-generic/source/odp_packet_flags.c > @@ -4,8 +4,8 @@ > * SPDX-License-Identifier: BSD-3-Clause > */ > > - #include <odp_packet_flags.h> > - #include <odp_packet_internal.h> > +#include <odp_packet_flags.h> > +#include <odp_packet_internal.h> > > > int odp_packet_error(odp_packet_t pkt) > @@ -113,4 +113,3 @@ void > odp_packet_outflag_l4_chksum(odp_packet_t pkt) > { > odp_packet_hdr(pkt)->output_flags.l4_chksum = 1; > } > - > diff --git a/platform/linux-generic/source/odp_queue.c > b/platform/linux-generic/source/odp_queue.c > index 648c18e..49bc766 100644 > --- a/platform/linux-generic/source/odp_queue.c > +++ b/platform/linux-generic/source/odp_queue.c > @@ -146,7 +146,6 @@ odp_queue_t odp_queue_create(const char > *name, odp_queue_type_t type, > continue; > > LOCK(&queue->s.lock); > - > if (queue->s.status == QUEUE_STATUS_FREE) { > queue_init(queue, name, type, param); > > @@ -157,28 +156,23 @@ odp_queue_t odp_queue_create(const char > *name, odp_queue_type_t type, > queue->s.status = > QUEUE_STATUS_READY; > > handle = queue->s.handle; > - > UNLOCK(&queue->s.lock); > break; > } > - > UNLOCK(&queue->s.lock); > } > > - > if (handle != ODP_QUEUE_INVALID && > (type == ODP_QUEUE_TYPE_SCHED || type == > ODP_QUEUE_TYPE_PKTIN)) { > odp_buffer_t buf; > > buf = odp_schedule_buffer_alloc(handle); > - > if (buf == ODP_BUFFER_INVALID) { > ODP_ERR("queue_init: sched buf alloc > failed\n"); > return ODP_QUEUE_INVALID; > } > > queue->s.sched_buf = buf; > - > odp_schedule_mask_set(handle, > queue->s.param.sched.prio); > } > > @@ -215,13 +209,11 @@ odp_queue_t odp_queue_lookup(const char > *name) > continue; > > LOCK(&queue->s.lock); > - > if (strcmp(name, queue->s.name > <http://s.name>) == 0) { > /* found it */ > UNLOCK(&queue->s.lock); > return queue->s.handle; > } > - > UNLOCK(&queue->s.lock); > } > > @@ -234,7 +226,6 @@ int queue_enq(queue_entry_t *queue, > odp_buffer_hdr_t *buf_hdr) > int sched = 0; > > LOCK(&queue->s.lock); > - > if (queue->s.head == NULL) { > /* Empty queue */ > queue->s.head = buf_hdr; > @@ -250,7 +241,6 @@ int queue_enq(queue_entry_t *queue, > odp_buffer_hdr_t *buf_hdr) > queue->s.status = QUEUE_STATUS_SCHED; > sched = 1; /* retval: schedule queue */ > } > - > UNLOCK(&queue->s.lock); > > /* Add queue to scheduling */ > @@ -274,7 +264,6 @@ int queue_enq_multi(queue_entry_t *queue, > odp_buffer_hdr_t *buf_hdr[], int num) > buf_hdr[num-1]->next = NULL; > > LOCK(&queue->s.lock); > - > /* Empty queue */ > if (queue->s.head == NULL) > queue->s.head = buf_hdr[0]; > @@ -287,7 +276,6 @@ int queue_enq_multi(queue_entry_t *queue, > odp_buffer_hdr_t *buf_hdr[], int num) > queue->s.status = QUEUE_STATUS_SCHED; > sched = 1; /* retval: schedule queue */ > } > - > UNLOCK(&queue->s.lock); > > /* Add queue to scheduling */ > @@ -411,7 +399,6 @@ int odp_queue_deq_multi(odp_queue_t > handle, odp_buffer_t buf[], int num) > } > > > - > odp_buffer_t odp_queue_deq(odp_queue_t handle) > { > queue_entry_t *queue; > diff --git a/platform/linux-generic/source/odp_rwlock.c > b/platform/linux-generic/source/odp_rwlock.c > index 19c58e1..c2b34e3 100644 > --- a/platform/linux-generic/source/odp_rwlock.c > +++ b/platform/linux-generic/source/odp_rwlock.c > @@ -59,5 +59,3 @@ void odp_rwlock_write_unlock(odp_rwlock_t > *rwlock) > { > odp_atomic_inc_u32((odp_atomic_u32_t > *)(intptr_t)&rwlock->cnt); > } > - > - > diff --git a/platform/linux-generic/source/odp_shared_memory.c > b/platform/linux-generic/source/odp_shared_memory.c > index c607c99..8288b46 100644 > --- a/platform/linux-generic/source/odp_shared_memory.c > +++ b/platform/linux-generic/source/odp_shared_memory.c > @@ -4,7 +4,6 @@ > * SPDX-License-Identifier: BSD-3-Clause > */ > > - > #include <odp_shared_memory.h> > #include <odp_internal.h> > #include <odp_spinlock.h> > @@ -50,7 +49,6 @@ typedef struct { > static odp_shm_table_t *odp_shm_tbl; > > > - > int odp_shm_init_global(void) > { > void *addr; > @@ -172,7 +170,6 @@ void *odp_shm_reserve(const char *name, > uint64_t size, uint64_t align) > } > > > - > void *odp_shm_lookup(const char *name) > { > int i; > @@ -194,7 +191,6 @@ void *odp_shm_lookup(const char *name) > } > > > - > void odp_shm_print_all(void) > { > int i; > @@ -226,12 +222,3 @@ void odp_shm_print_all(void) > > printf("\n"); > } > - > - > - > - > - > - > - > - > - > diff --git a/platform/linux-generic/source/odp_spinlock.c > b/platform/linux-generic/source/odp_spinlock.c > index da98278..4eba015 100644 > --- a/platform/linux-generic/source/odp_spinlock.c > +++ b/platform/linux-generic/source/odp_spinlock.c > @@ -38,6 +38,3 @@ int odp_spinlock_is_locked(odp_spinlock_t > *spinlock) > { > return spinlock->lock != 0; > } > - > - > - > diff --git a/platform/linux-generic/source/odp_system_info.c > b/platform/linux-generic/source/odp_system_info.c > index 17617b0..f78b746 100644 > --- a/platform/linux-generic/source/odp_system_info.c > +++ b/platform/linux-generic/source/odp_system_info.c > @@ -52,7 +52,6 @@ static int sysconf_core_count(void) > long ret; > > ret = sysconf(_SC_NPROCESSORS_CONF); > - > if (ret < 0) > return 0; > > @@ -72,7 +71,6 @@ static int systemcpu_cache_line_size(void) > int size = 0; > > file = fopen(CACHE_LNSZ_FILE, "rt"); > - > if (file == NULL) { > /* File not found */ > return 0; > @@ -96,7 +94,6 @@ static int huge_page_size(void) > int size = 0; > > dir = opendir(HUGE_PAGE_DIR); > - > if (dir == NULL) { > ODP_ERR("%s not found\n", HUGE_PAGE_DIR); > return 0; > @@ -137,7 +134,6 @@ static int cpuinfo_x86(FILE *file, > odp_system_info_t *sysinfo) > while (fgets(str, sizeof(str), file) != NULL && count > > 0) { > if (!mhz) { > pos = strstr(str, "cpu MHz"); > - > if (pos) { > sscanf(pos, "cpu MHz : %lf", > &mhz); > count--; > @@ -146,7 +142,6 @@ static int cpuinfo_x86(FILE *file, > odp_system_info_t *sysinfo) > > if (!model) { > pos = strstr(str, "model name"); > - > if (pos) { > int len; > pos = strchr(str, ':'); > @@ -293,7 +288,6 @@ static int systemcpu(odp_system_info_t > *sysinfo) > int ret; > > ret = sysconf_core_count(); > - > if (ret == 0) { > ODP_ERR("sysconf_core_count failed.\n"); > return -1; > @@ -303,7 +297,6 @@ static int systemcpu(odp_system_info_t > *sysinfo) > > > ret = systemcpu_cache_line_size(); > - > if (ret == 0) { > ODP_ERR("systemcpu_cache_line_size failed.\n"); > return -1; > @@ -333,7 +326,6 @@ static int systemcpu(odp_system_info_t > *sysinfo) > int ret; > > ret = sysconf_core_count(); > - > if (ret == 0) { > ODP_ERR("sysconf_core_count failed.\n"); > return -1; > @@ -364,7 +356,6 @@ int odp_system_info_init(void) > odp_system_info.page_size = ODP_PAGE_SIZE; > > file = fopen("/proc/cpuinfo", "rt"); > - > if (file == NULL) { > ODP_ERR("Failed to open /proc/cpuinfo\n"); > return -1; > diff --git a/platform/linux-generic/source/odp_thread.c > b/platform/linux-generic/source/odp_thread.c > index 4bee2aa..eaa480e 100644 > --- a/platform/linux-generic/source/odp_thread.c > +++ b/platform/linux-generic/source/odp_thread.c > @@ -4,7 +4,6 @@ > * SPDX-License-Identifier: BSD-3-Clause > */ > > - > #include <odp_thread.h> > #include <odp_internal.h> > #include <odp_atomic.h> > @@ -14,8 +13,6 @@ > #include <stdio.h> > > > - > - > typedef struct { > int thr_id; > int phys_core; > @@ -23,8 +20,6 @@ typedef struct { > } odp_thread_tbl_t; > > > - > - > /* Globals */ > static odp_thread_tbl_t odp_thread_tbl[ODP_CONFIG_MAX_THREADS]; > static odp_atomic_int_t num_threads; > @@ -48,7 +43,7 @@ void odp_thread_init_local(int thr_id) > > int odp_thread_create(int phys_core) > { > - int id = -1; > + int id; > > id = odp_atomic_fetch_add_int(&num_threads, 1); > > @@ -71,5 +66,3 @@ int odp_thread_core(void) > { > return odp_this_thread->phys_core; > } > - > - > diff --git a/platform/linux-generic/source/odp_timer.c > b/platform/linux-generic/source/odp_timer.c > index 824ec0e..001b505 100644 > --- a/platform/linux-generic/source/odp_timer.c > +++ b/platform/linux-generic/source/odp_timer.c > @@ -168,12 +168,10 @@ int odp_timer_init_global(void) > > timer_init(); > > - > return 0; > } > > > - > odp_timer_t odp_timer_create(const char *name, > odp_buffer_pool_t pool, > uint64_t resolution, uint64_t > min_tmo, > uint64_t max_tmo) > @@ -185,7 +183,6 @@ odp_timer_t odp_timer_create(const char > *name, odp_buffer_pool_t pool, > return ODP_TIMER_INVALID; > > id = odp_atomic_fetch_inc_int(&odp_timer.num_timers); > - > if (id >= NUM_TIMERS) > return ODP_TIMER_INVALID; > > @@ -213,14 +210,12 @@ odp_timer_tmo_t > odp_timer_absolute_tmo(odp_timer_t timer, uint64_t tmo_tick, > id = timer - 1; > > cur_tick = odp_timer.timer[id].cur_tick; > - > if (tmo_tick <= cur_tick) { > ODP_DBG("timeout too close\n"); > return ODP_TIMER_TMO_INVALID; > } > > tick = tmo_tick - cur_tick; > - > if (tick > MAX_TICKS) { > ODP_DBG("timeout too far\n"); > return ODP_TIMER_TMO_INVALID; > @@ -229,7 +224,6 @@ odp_timer_tmo_t > odp_timer_absolute_tmo(odp_timer_t timer, uint64_t tmo_tick, > tick = (cur_tick + tick) % MAX_TICKS; > > tmo_buf = odp_buffer_alloc(odp_timer.timer[id].pool); > - > if (tmo_buf == ODP_BUFFER_INVALID) { > ODP_DBG("alloc failed\n"); > return ODP_TIMER_TMO_INVALID; > @@ -254,13 +248,11 @@ odp_timer_tmo_t > odp_timer_absolute_tmo(odp_timer_t timer, uint64_t tmo_tick, > } > > > - > uint64_t odp_timer_tick_to_ns(odp_timer_t timer, uint64_t ticks) > { > uint32_t id; > > id = timer - 1; > - > return ticks * odp_timer.timer[id].resolution_ns; > } > > @@ -270,7 +262,6 @@ uint64_t odp_timer_ns_to_tick(odp_timer_t > timer, uint64_t ns) > uint32_t id; > > id = timer - 1; > - > return ns / odp_timer.timer[id].resolution_ns; > } > > @@ -280,7 +271,6 @@ uint64_t odp_timer_resolution(odp_timer_t > timer) > uint32_t id; > > id = timer - 1; > - > return odp_timer.timer[id].resolution_ns; > } > > @@ -290,7 +280,6 @@ uint64_t odp_timer_maximum_tmo(odp_timer_t > timer) > uint32_t id; > > id = timer - 1; > - > return odp_timer.timer[id].max_ticks; > } > > @@ -300,6 +289,5 @@ uint64_t > odp_timer_current_tick(odp_timer_t timer) > uint32_t id; > > id = timer - 1; > - > return odp_timer.timer[id].cur_tick; > } > -- > 1.8.5.1.163.gd7aced9 > > -- > You received this message because you are subscribed to the Google > Groups "LNG ODP Sub-team - lng-odp@linaro.org > <mailto:lng-odp@linaro.org>" group. > To unsubscribe from this group and stop receiving emails from it, > send an email to lng-odp+unsubscribe@linaro.org > <mailto:lng-odp+unsubscribe@linaro.org>. > To post to this group, send email to lng-odp@linaro.org > <mailto:lng-odp@linaro.org>. > Visit this group at > http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/30ab39ee-fe27-4fbd-8ff7-5fc662eca8b5%40linaro.org > <https://groups.google.com/a/linaro.org/d/msgid/lng-odp/30ab39ee-fe27-4fbd-8ff7-5fc662eca8b5%40linaro.org?utm_medium=email&utm_source=footer>. > > > For more options, visit > https://groups.google.com/a/linaro.org/d/optout. > > > -- > You received this message because you are subscribed to the Google > Groups "LNG ODP Sub-team - lng-odp@linaro.org" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to lng-odp+unsubscribe@linaro.org > <mailto:lng-odp+unsubscribe@linaro.org>. > To post to this group, send email to lng-odp@linaro.org > <mailto:lng-odp@linaro.org>. > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/CAKb83kZyvkbT%2BRpSLb3Nnv%3DWpKC7ohj8gpAUEAmZr5QZxko6Yw%40mail.gmail.com > <https://groups.google.com/a/linaro.org/d/msgid/lng-odp/CAKb83kZyvkbT%2BRpSLb3Nnv%3DWpKC7ohj8gpAUEAmZr5QZxko6Yw%40mail.gmail.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/a/linaro.org/d/optout.
diff --git a/platform/linux-generic/include/odp_buffer_pool_internal.h b/platform/linux-generic/include/odp_buffer_pool_internal.h index 380de36..381482f 100644 --- a/platform/linux-generic/include/odp_buffer_pool_internal.h +++ b/platform/linux-generic/include/odp_buffer_pool_internal.h @@ -51,7 +51,6 @@ struct pool_entry_s { uint64_t free_bufs; char name[ODP_BUFFER_POOL_NAME_LEN]; - odp_buffer_pool_t pool ODP_ALIGNED_CACHE; uintptr_t buf_base; size_t buf_size; diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index ff34b5e..fb3be79 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -19,18 +19,14 @@ extern "C" { #endif - int odp_system_info_init(void); - void odp_thread_init_global(void); void odp_thread_init_local(int thr_id); - int odp_shm_init_global(void); int odp_shm_init_local(void); - int odp_buffer_pool_init_global(void); int odp_pktio_init_global(void); @@ -38,14 +34,11 @@ int odp_pktio_init_local(void); int odp_queue_init_global(void); - int odp_schedule_init_global(void); int odp_schedule_init_local(void); - int odp_timer_init_global(void); - #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/include/odp_packet_socket.h b/platform/linux-generic/include/odp_packet_socket.h index fe216bb..4dea649 100644 --- a/platform/linux-generic/include/odp_packet_socket.h +++ b/platform/linux-generic/include/odp_packet_socket.h @@ -46,8 +46,6 @@ /** Max transmit (Tx) burst size*/ #define ODP_PACKET_SOCKET_MAX_BURST_TX 32 - - #if (ODP_PACKET_SOCKET_MODE == ODP_PACKET_SOCKET_BASIC) || \ (ODP_PACKET_SOCKET_MODE == ODP_PACKET_SOCKET_MMSG) diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index fede56a..8b6c517 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -118,4 +118,3 @@ static inline queue_entry_t *queue_to_qentry(odp_queue_t handle) #endif #endif - diff --git a/platform/linux-generic/include/odp_schedule_internal.h b/platform/linux-generic/include/odp_schedule_internal.h index b0135c5..7b943bd 100644 --- a/platform/linux-generic/include/odp_schedule_internal.h +++ b/platform/linux-generic/include/odp_schedule_internal.h @@ -29,5 +29,3 @@ void odp_schedule_queue(odp_queue_t queue, int prio); #endif #endif - - diff --git a/platform/linux-generic/include/odp_spin_internal.h b/platform/linux-generic/include/odp_spin_internal.h index e70ccf1..1061e52 100644 --- a/platform/linux-generic/include/odp_spin_internal.h +++ b/platform/linux-generic/include/odp_spin_internal.h @@ -60,8 +60,6 @@ static inline void odp_spin(void) } - - #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/source/odp_buffer.c b/platform/linux-generic/source/odp_buffer.c index f5b02fd..f506d35 100644 --- a/platform/linux-generic/source/odp_buffer.c +++ b/platform/linux-generic/source/odp_buffer.c @@ -4,7 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ - #include <odp_buffer.h> #include <odp_buffer_internal.h> #include <odp_buffer_pool_internal.h> @@ -13,10 +12,6 @@ #include <stdio.h> - - - - void *odp_buffer_addr(odp_buffer_t buf) { odp_buffer_hdr_t *hdr = odp_buf_to_hdr(buf); @@ -105,7 +100,6 @@ int odp_buffer_snprint(char *str, size_t n, odp_buffer_t buf) } - void odp_buffer_print(odp_buffer_t buf) { int max_len = 512; @@ -117,8 +111,3 @@ void odp_buffer_print(odp_buffer_t buf) printf("\n%s\n", str); } - - - - - diff --git a/platform/linux-generic/source/odp_buffer_pool.c b/platform/linux-generic/source/odp_buffer_pool.c index fecdb18..90214ba 100644 --- a/platform/linux-generic/source/odp_buffer_pool.c +++ b/platform/linux-generic/source/odp_buffer_pool.c @@ -93,7 +93,6 @@ int odp_buffer_pool_init_global(void) memset(pool_tbl, 0, sizeof(pool_table_t)); - for (i = 0; i < ODP_CONFIG_BUFFER_POOLS; i++) { /* init locks */ pool_entry_t *pool = &pool_tbl->pool[i]; @@ -108,7 +107,6 @@ int odp_buffer_pool_init_global(void) ODP_DBG(" pool_entry_t size %zu\n", sizeof(pool_entry_t)); ODP_DBG(" odp_buffer_hdr_t size %zu\n", sizeof(odp_buffer_hdr_t)); ODP_DBG("\n"); - return 0; } @@ -118,7 +116,6 @@ static odp_buffer_hdr_t *index_to_hdr(pool_entry_t *pool, uint32_t index) odp_buffer_hdr_t *hdr; hdr = (odp_buffer_hdr_t *)(pool->s.buf_base + index * pool->s.buf_size); - return hdr; } @@ -139,7 +136,6 @@ static uint32_t rem_buf_index(odp_buffer_chunk_hdr_t *chunk_hdr) i = chunk_hdr->chunk.num_bufs - 1; index = chunk_hdr->chunk.buf_index[i]; chunk_hdr->chunk.num_bufs--; - return index; } @@ -150,7 +146,6 @@ static odp_buffer_chunk_hdr_t *next_chunk(pool_entry_t *pool, uint32_t index; index = chunk_hdr->chunk.buf_index[ODP_BUFS_PER_CHUNK-1]; - if (index == NULL_INDEX) return NULL; else @@ -163,19 +158,16 @@ static odp_buffer_chunk_hdr_t *rem_chunk(pool_entry_t *pool) odp_buffer_chunk_hdr_t *chunk_hdr; chunk_hdr = pool->s.head; - if (chunk_hdr == NULL) { /* Pool is empty */ return NULL; } pool->s.head = next_chunk(pool, chunk_hdr); - pool->s.free_bufs -= ODP_BUFS_PER_CHUNK; /* unlink */ rem_buf_index(chunk_hdr); - return chunk_hdr; } @@ -185,12 +177,10 @@ static void add_chunk(pool_entry_t *pool, odp_buffer_chunk_hdr_t *chunk_hdr) if (pool->s.head) { /* link pool head to the chunk */ add_buf_index(chunk_hdr, pool->s.head->buf_hdr.index); - } else { + } else add_buf_index(chunk_hdr, NULL_INDEX); - } pool->s.head = chunk_hdr; - pool->s.free_bufs += ODP_BUFS_PER_CHUNK; } @@ -255,24 +245,22 @@ static void link_bufs(pool_entry_t *pool) uintptr_t pool_base; int buf_type; - buf_type = pool->s.buf_type; payload_size = pool->s.payload_size; payload_align = pool->s.payload_align; pool_size = pool->s.pool_size; pool_base = (uintptr_t) pool->s.pool_base_addr; - if (buf_type == ODP_BUFFER_TYPE_RAW) { + if (buf_type == ODP_BUFFER_TYPE_RAW) hdr_size = sizeof(odp_buffer_hdr_t); - } else if (buf_type == ODP_BUFFER_TYPE_PACKET) { + else if (buf_type == ODP_BUFFER_TYPE_PACKET) hdr_size = sizeof(odp_packet_hdr_t); - } else { + else { ODP_ERR("odp_buffer_pool_create: Bad type %i\n", buf_type); exit(0); } - /* Chunk must fit into buffer payload.*/ min_size = sizeof(odp_buffer_chunk_hdr_t) - hdr_size; if (payload_size < min_size) @@ -291,7 +279,6 @@ static void link_bufs(pool_entry_t *pool) else size = payload_align + offset; - /* First buffer */ buf_base = ODP_ALIGN_ROUNDUP(pool_base + offset, payload_align) - offset; @@ -382,17 +369,14 @@ odp_buffer_pool_t odp_buffer_pool_lookup(const char *name) pool = get_pool_entry(i); LOCK(&pool->s.lock); - if (strcmp(name, pool->s.name) == 0) { /* found it */ UNLOCK(&pool->s.lock); return i; } - UNLOCK(&pool->s.lock); } - return ODP_BUFFER_POOL_INVALID; } @@ -432,8 +416,6 @@ odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool_id) handle = hdr->handle; } - - return handle.u32; } @@ -450,7 +432,6 @@ void odp_buffer_free(odp_buffer_t buf) pool = get_pool_entry(pool_id); chunk_hdr = local_chunk[pool_id]; - if (chunk_hdr && chunk_hdr->chunk.num_bufs == ODP_BUFS_PER_CHUNK - 1) { /* Current chunk is full. Push back to the pool */ LOCK(&pool->s.lock); diff --git a/platform/linux-generic/source/odp_coremask.c b/platform/linux-generic/source/odp_coremask.c index 22be78f..c55eb72 100644 --- a/platform/linux-generic/source/odp_coremask.c +++ b/platform/linux-generic/source/odp_coremask.c @@ -50,10 +50,8 @@ void odp_coremask_from_u64(const uint64_t *u64, int num, odp_coremask_t *mask) num = ODP_COREMASK_SIZE_U64; } - for (i = 0; i < num; i++) { - /* */ + for (i = 0; i < num; i++) mask->_u64[0] |= u64[i]; - } } void odp_coremask_set(int core, odp_coremask_t *mask) diff --git a/platform/linux-generic/source/odp_linux.c b/platform/linux-generic/source/odp_linux.c index 42b7d89..6adeb3f 100644 --- a/platform/linux-generic/source/odp_linux.c +++ b/platform/linux-generic/source/odp_linux.c @@ -28,7 +28,6 @@ typedef struct { } odp_start_args_t; - static void *odp_run_start_routine(void *arg) { odp_start_args_t *start_args = arg; @@ -40,8 +39,6 @@ static void *odp_run_start_routine(void *arg) } - - void odp_linux_pthread_create(odp_linux_pthread_t *thread_tbl, int num, int first_core, void *(*start_routine) (void *), void *arg) { @@ -58,7 +55,6 @@ void odp_linux_pthread_create(odp_linux_pthread_t *thread_tbl, int num, memset(thread_tbl, 0, num * sizeof(odp_linux_pthread_t)); - for (i = 0; i < num; i++) { pthread_attr_init(&thread_tbl[i].attr); @@ -83,7 +79,6 @@ void odp_linux_pthread_create(odp_linux_pthread_t *thread_tbl, int num, } - void odp_linux_pthread_join(odp_linux_pthread_t *thread_tbl, int num) { int i; @@ -93,5 +88,3 @@ void odp_linux_pthread_join(odp_linux_pthread_t *thread_tbl, int num) pthread_join(thread_tbl[i].thread, NULL); } } - - diff --git a/platform/linux-generic/source/odp_packet.c b/platform/linux-generic/source/odp_packet.c index 5f07374..8af5169 100644 --- a/platform/linux-generic/source/odp_packet.c +++ b/platform/linux-generic/source/odp_packet.c @@ -87,7 +87,6 @@ void odp_packet_set_l2_offset(odp_packet_t pkt, size_t offset) odp_packet_hdr(pkt)->l2_offset = offset; } - uint8_t *odp_packet_l3(odp_packet_t pkt) { const size_t offset = odp_packet_l3_offset(pkt); @@ -108,7 +107,6 @@ void odp_packet_set_l3_offset(odp_packet_t pkt, size_t offset) odp_packet_hdr(pkt)->l3_offset = offset; } - uint8_t *odp_packet_l4(odp_packet_t pkt) { const size_t offset = odp_packet_l4_offset(pkt); @@ -330,4 +328,3 @@ void odp_packet_print(odp_packet_t pkt) printf("\n%s\n", str); } - diff --git a/platform/linux-generic/source/odp_packet_flags.c b/platform/linux-generic/source/odp_packet_flags.c index 0fd0aa9..992b94b 100644 --- a/platform/linux-generic/source/odp_packet_flags.c +++ b/platform/linux-generic/source/odp_packet_flags.c @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ - #include <odp_packet_flags.h> - #include <odp_packet_internal.h> +#include <odp_packet_flags.h> +#include <odp_packet_internal.h> int odp_packet_error(odp_packet_t pkt) @@ -113,4 +113,3 @@ void odp_packet_outflag_l4_chksum(odp_packet_t pkt) { odp_packet_hdr(pkt)->output_flags.l4_chksum = 1; } - diff --git a/platform/linux-generic/source/odp_queue.c b/platform/linux-generic/source/odp_queue.c index 648c18e..49bc766 100644 --- a/platform/linux-generic/source/odp_queue.c +++ b/platform/linux-generic/source/odp_queue.c @@ -146,7 +146,6 @@ odp_queue_t odp_queue_create(const char *name, odp_queue_type_t type, continue; LOCK(&queue->s.lock); - if (queue->s.status == QUEUE_STATUS_FREE) { queue_init(queue, name, type, param); @@ -157,28 +156,23 @@ odp_queue_t odp_queue_create(const char *name, odp_queue_type_t type, queue->s.status = QUEUE_STATUS_READY; handle = queue->s.handle; - UNLOCK(&queue->s.lock); break; } - UNLOCK(&queue->s.lock); } - if (handle != ODP_QUEUE_INVALID && (type == ODP_QUEUE_TYPE_SCHED || type == ODP_QUEUE_TYPE_PKTIN)) { odp_buffer_t buf; buf = odp_schedule_buffer_alloc(handle); - if (buf == ODP_BUFFER_INVALID) { ODP_ERR("queue_init: sched buf alloc failed\n"); return ODP_QUEUE_INVALID; } queue->s.sched_buf = buf; - odp_schedule_mask_set(handle, queue->s.param.sched.prio); } @@ -215,13 +209,11 @@ odp_queue_t odp_queue_lookup(const char *name) continue; LOCK(&queue->s.lock); - if (strcmp(name, queue->s.name) == 0) { /* found it */ UNLOCK(&queue->s.lock); return queue->s.handle; } - UNLOCK(&queue->s.lock); } @@ -234,7 +226,6 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr) int sched = 0; LOCK(&queue->s.lock); - if (queue->s.head == NULL) { /* Empty queue */ queue->s.head = buf_hdr; @@ -250,7 +241,6 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr) queue->s.status = QUEUE_STATUS_SCHED; sched = 1; /* retval: schedule queue */ } - UNLOCK(&queue->s.lock); /* Add queue to scheduling */ @@ -274,7 +264,6 @@ int queue_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num) buf_hdr[num-1]->next = NULL; LOCK(&queue->s.lock); - /* Empty queue */ if (queue->s.head == NULL) queue->s.head = buf_hdr[0]; @@ -287,7 +276,6 @@ int queue_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num) queue->s.status = QUEUE_STATUS_SCHED; sched = 1; /* retval: schedule queue */ } - UNLOCK(&queue->s.lock); /* Add queue to scheduling */ @@ -411,7 +399,6 @@ int odp_queue_deq_multi(odp_queue_t handle, odp_buffer_t buf[], int num) } - odp_buffer_t odp_queue_deq(odp_queue_t handle) { queue_entry_t *queue; diff --git a/platform/linux-generic/source/odp_rwlock.c b/platform/linux-generic/source/odp_rwlock.c index 19c58e1..c2b34e3 100644 --- a/platform/linux-generic/source/odp_rwlock.c +++ b/platform/linux-generic/source/odp_rwlock.c @@ -59,5 +59,3 @@ void odp_rwlock_write_unlock(odp_rwlock_t *rwlock) { odp_atomic_inc_u32((odp_atomic_u32_t *)(intptr_t)&rwlock->cnt); } - - diff --git a/platform/linux-generic/source/odp_shared_memory.c b/platform/linux-generic/source/odp_shared_memory.c index c607c99..8288b46 100644 --- a/platform/linux-generic/source/odp_shared_memory.c +++ b/platform/linux-generic/source/odp_shared_memory.c @@ -4,7 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ - #include <odp_shared_memory.h> #include <odp_internal.h> #include <odp_spinlock.h> @@ -50,7 +49,6 @@ typedef struct { static odp_shm_table_t *odp_shm_tbl; - int odp_shm_init_global(void) { void *addr; @@ -172,7 +170,6 @@ void *odp_shm_reserve(const char *name, uint64_t size, uint64_t align) } - void *odp_shm_lookup(const char *name) { int i; @@ -194,7 +191,6 @@ void *odp_shm_lookup(const char *name) } - void odp_shm_print_all(void) { int i; @@ -226,12 +222,3 @@ void odp_shm_print_all(void) printf("\n"); } - - - - - - - - - diff --git a/platform/linux-generic/source/odp_spinlock.c b/platform/linux-generic/source/odp_spinlock.c index da98278..4eba015 100644 --- a/platform/linux-generic/source/odp_spinlock.c +++ b/platform/linux-generic/source/odp_spinlock.c @@ -38,6 +38,3 @@ int odp_spinlock_is_locked(odp_spinlock_t *spinlock) { return spinlock->lock != 0; } - - - diff --git a/platform/linux-generic/source/odp_system_info.c b/platform/linux-generic/source/odp_system_info.c index 17617b0..f78b746 100644 --- a/platform/linux-generic/source/odp_system_info.c +++ b/platform/linux-generic/source/odp_system_info.c @@ -52,7 +52,6 @@ static int sysconf_core_count(void) long ret; ret = sysconf(_SC_NPROCESSORS_CONF); - if (ret < 0) return 0; @@ -72,7 +71,6 @@ static int systemcpu_cache_line_size(void) int size = 0; file = fopen(CACHE_LNSZ_FILE, "rt"); - if (file == NULL) { /* File not found */ return 0; @@ -96,7 +94,6 @@ static int huge_page_size(void) int size = 0; dir = opendir(HUGE_PAGE_DIR); - if (dir == NULL) { ODP_ERR("%s not found\n", HUGE_PAGE_DIR); return 0; @@ -137,7 +134,6 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo) while (fgets(str, sizeof(str), file) != NULL && count > 0) { if (!mhz) { pos = strstr(str, "cpu MHz"); - if (pos) { sscanf(pos, "cpu MHz : %lf", &mhz); count--; @@ -146,7 +142,6 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo) if (!model) { pos = strstr(str, "model name"); - if (pos) { int len; pos = strchr(str, ':'); @@ -293,7 +288,6 @@ static int systemcpu(odp_system_info_t *sysinfo) int ret; ret = sysconf_core_count(); - if (ret == 0) { ODP_ERR("sysconf_core_count failed.\n"); return -1; @@ -303,7 +297,6 @@ static int systemcpu(odp_system_info_t *sysinfo) ret = systemcpu_cache_line_size(); - if (ret == 0) { ODP_ERR("systemcpu_cache_line_size failed.\n"); return -1; @@ -333,7 +326,6 @@ static int systemcpu(odp_system_info_t *sysinfo) int ret; ret = sysconf_core_count(); - if (ret == 0) { ODP_ERR("sysconf_core_count failed.\n"); return -1; @@ -364,7 +356,6 @@ int odp_system_info_init(void) odp_system_info.page_size = ODP_PAGE_SIZE; file = fopen("/proc/cpuinfo", "rt"); - if (file == NULL) { ODP_ERR("Failed to open /proc/cpuinfo\n"); return -1; diff --git a/platform/linux-generic/source/odp_thread.c b/platform/linux-generic/source/odp_thread.c index 4bee2aa..eaa480e 100644 --- a/platform/linux-generic/source/odp_thread.c +++ b/platform/linux-generic/source/odp_thread.c @@ -4,7 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ - #include <odp_thread.h> #include <odp_internal.h> #include <odp_atomic.h> @@ -14,8 +13,6 @@ #include <stdio.h> - - typedef struct { int thr_id; int phys_core; @@ -23,8 +20,6 @@ typedef struct { } odp_thread_tbl_t; - - /* Globals */ static odp_thread_tbl_t odp_thread_tbl[ODP_CONFIG_MAX_THREADS]; static odp_atomic_int_t num_threads; @@ -48,7 +43,7 @@ void odp_thread_init_local(int thr_id) int odp_thread_create(int phys_core) { - int id = -1; + int id; id = odp_atomic_fetch_add_int(&num_threads, 1); @@ -71,5 +66,3 @@ int odp_thread_core(void) { return odp_this_thread->phys_core; } - - diff --git a/platform/linux-generic/source/odp_timer.c b/platform/linux-generic/source/odp_timer.c index 824ec0e..001b505 100644 --- a/platform/linux-generic/source/odp_timer.c +++ b/platform/linux-generic/source/odp_timer.c @@ -168,12 +168,10 @@ int odp_timer_init_global(void) timer_init(); - return 0; } - odp_timer_t odp_timer_create(const char *name, odp_buffer_pool_t pool, uint64_t resolution, uint64_t min_tmo, uint64_t max_tmo) @@ -185,7 +183,6 @@ odp_timer_t odp_timer_create(const char *name, odp_buffer_pool_t pool, return ODP_TIMER_INVALID; id = odp_atomic_fetch_inc_int(&odp_timer.num_timers); - if (id >= NUM_TIMERS) return ODP_TIMER_INVALID; @@ -213,14 +210,12 @@ odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t timer, uint64_t tmo_tick, id = timer - 1; cur_tick = odp_timer.timer[id].cur_tick; - if (tmo_tick <= cur_tick) { ODP_DBG("timeout too close\n"); return ODP_TIMER_TMO_INVALID; } tick = tmo_tick - cur_tick; - if (tick > MAX_TICKS) { ODP_DBG("timeout too far\n"); return ODP_TIMER_TMO_INVALID; @@ -229,7 +224,6 @@ odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t timer, uint64_t tmo_tick, tick = (cur_tick + tick) % MAX_TICKS; tmo_buf = odp_buffer_alloc(odp_timer.timer[id].pool); - if (tmo_buf == ODP_BUFFER_INVALID) { ODP_DBG("alloc failed\n"); return ODP_TIMER_TMO_INVALID; @@ -254,13 +248,11 @@ odp_timer_tmo_t odp_timer_absolute_tmo(odp_timer_t timer, uint64_t tmo_tick, } - uint64_t odp_timer_tick_to_ns(odp_timer_t timer, uint64_t ticks) { uint32_t id; id = timer - 1; - return ticks * odp_timer.timer[id].resolution_ns; } @@ -270,7 +262,6 @@ uint64_t odp_timer_ns_to_tick(odp_timer_t timer, uint64_t ns) uint32_t id; id = timer - 1; - return ns / odp_timer.timer[id].resolution_ns; } @@ -280,7 +271,6 @@ uint64_t odp_timer_resolution(odp_timer_t timer) uint32_t id; id = timer - 1; - return odp_timer.timer[id].resolution_ns; } @@ -290,7 +280,6 @@ uint64_t odp_timer_maximum_tmo(odp_timer_t timer) uint32_t id; id = timer - 1; - return odp_timer.timer[id].max_ticks; } @@ -300,6 +289,5 @@ uint64_t odp_timer_current_tick(odp_timer_t timer) uint32_t id; id = timer - 1; - return odp_timer.timer[id].cur_tick; }
Remove not needed empty lines and minor style clean up. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- .../include/odp_buffer_pool_internal.h | 1 - platform/linux-generic/include/odp_internal.h | 7 ------ platform/linux-generic/include/odp_packet_socket.h | 2 -- .../linux-generic/include/odp_queue_internal.h | 1 - .../linux-generic/include/odp_schedule_internal.h | 2 -- platform/linux-generic/include/odp_spin_internal.h | 2 -- platform/linux-generic/source/odp_buffer.c | 11 --------- platform/linux-generic/source/odp_buffer_pool.c | 27 ++++------------------ platform/linux-generic/source/odp_coremask.c | 4 +--- platform/linux-generic/source/odp_linux.c | 7 ------ platform/linux-generic/source/odp_packet.c | 3 --- platform/linux-generic/source/odp_packet_flags.c | 5 ++-- platform/linux-generic/source/odp_queue.c | 13 ----------- platform/linux-generic/source/odp_rwlock.c | 2 -- platform/linux-generic/source/odp_shared_memory.c | 13 ----------- platform/linux-generic/source/odp_spinlock.c | 3 --- platform/linux-generic/source/odp_system_info.c | 9 -------- platform/linux-generic/source/odp_thread.c | 9 +------- platform/linux-generic/source/odp_timer.c | 12 ---------- 19 files changed, 8 insertions(+), 125 deletions(-)