mm/: Coding style clean-up

Run tools/nxstyle against all C files under mm/ and correct coding standard violations.
This commit is contained in:
Gregory Nutt 2020-02-13 07:58:07 -06:00 committed by Abdelatif Guettouche
parent 3381ecb913
commit 1382ea5447
23 changed files with 79 additions and 55 deletions

View File

@ -132,9 +132,9 @@ static FAR struct iob_qentry_s *iob_allocwait_qentry(void)
ret = nxsem_wait_uninterruptible(&g_qentry_sem);
if (ret >= 0)
{
/* When we wake up from wait successfully, an I/O buffer chain container was
* freed and we hold a count for one IOB. Unless somehting
* failed, we should have an IOB waiting for us in the
/* When we wake up from wait successfully, an I/O buffer chain
* container was freed and we hold a count for one IOB. Unless
* something failed, we should have an IOB waiting for us in the
* committed list.
*/

View File

@ -250,5 +250,6 @@ int iob_trycopyin(FAR struct iob_s *iob, FAR const uint8_t *src,
unsigned int len, unsigned int offset, bool throttled,
enum iob_user_e consumerid)
{
return iob_copyin_internal(iob, src, len, offset, throttled, false, consumerid);
return iob_copyin_internal(iob, src, len, offset, throttled, false,
consumerid);
}

View File

@ -169,7 +169,8 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob,
#if CONFIG_IOB_THROTTLE > 0
nxsem_post(&g_throttle_sem);
DEBUGASSERT(g_throttle_sem.semcount <= (CONFIG_IOB_NBUFFERS - CONFIG_IOB_THROTTLE));
DEBUGASSERT(g_throttle_sem.semcount <=
(CONFIG_IOB_NBUFFERS - CONFIG_IOB_THROTTLE));
#endif
#ifdef CONFIG_IOB_NOTIFIER

View File

@ -78,6 +78,7 @@ int iob_navail(bool throttled)
ret -= CONFIG_IOB_THROTTLE;
}
#endif
if (ret < 0)
{
ret = 0;

View File

@ -107,7 +107,6 @@ void iob_stats_onfree(enum iob_user_e producerid)
/* Increment the global statistic as well */
g_iobuserstats[IOBUSER_GLOBAL].totalproduced++;
}
/****************************************************************************

View File

@ -115,6 +115,7 @@ int main(int argc, char **argv)
{
buffer1[i] = (uint8_t)(i & 0xff);
}
memset(buffer2, 0xff, 4096);
iob_copyin(iob, buffer2, 47, 0, false, IOBUSER_UNITTEST);

View File

@ -213,7 +213,8 @@ FAR void *gran_alloc(GRAN_HANDLE handle, size_t size)
}
/* We know that the first free bit is now within the lower 4 bits
* of 'curr'. Check if we have the allocation at this bit position.
* of 'curr'. Check if we have the allocation at this bit
* position.
*/
else if ((curr & mask) == 0)

View File

@ -86,5 +86,4 @@ void gran_leave_critical(FAR struct gran_s *priv)
#endif
}
#endif /* CONFIG_GRAN */

View File

@ -115,9 +115,9 @@ void gran_free(GRAN_HANDLE handle, FAR void *memory, size_t size)
/* Clear bits in the second GAT entry */
gatmask = 0xffffffff >> (32 - ngranules);
DEBUGASSERT((priv->gat[gatidx+1] & gatmask) == gatmask);
DEBUGASSERT((priv->gat[gatidx + 1] & gatmask) == gatmask);
priv->gat[gatidx+1] &= ~gatmask;
priv->gat[gatidx + 1] &= ~gatmask;
}
/* Handle the case where where all of the granules came from one entry */

View File

@ -101,9 +101,9 @@ void gran_mark_allocated(FAR struct gran_s *priv, uintptr_t alloc,
/* Mark bits in the second GAT entry */
gatmask = 0xffffffff >> (32 - ngranules);
DEBUGASSERT((priv->gat[gatidx+1] & gatmask) == 0);
DEBUGASSERT((priv->gat[gatidx + 1] & gatmask) == 0);
priv->gat[gatidx+1] |= gatmask;
priv->gat[gatidx + 1] |= gatmask;
}
/* Handle the case where where all of the granules come from one entry */

View File

@ -51,7 +51,9 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* CONFIG_MM_PGALLOC - Enable page allocator support
* CONFIG_MM_PGSIZE - The page size. Must be one of {1024, 2048,
* 4096, 8192, or 16384}. This is easily extensible, but only those

View File

@ -112,7 +112,8 @@ void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size,
/* Get and initialize the new terminal node in the heap */
newnode = (FAR struct mm_allocnode_s *)(blockend - SIZEOF_MM_ALLOCNODE);
newnode = (FAR struct mm_allocnode_s *)
(blockend - SIZEOF_MM_ALLOCNODE);
newnode->size = SIZEOF_MM_ALLOCNODE;
newnode->preceding = oldnode->size | MM_ALLOC_BIT;

View File

@ -85,7 +85,7 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
* crazy.
*/
DEBUGASSERT(heapsize <= MMSIZE_MAX+1);
DEBUGASSERT(heapsize <= MMSIZE_MAX + 1);
#endif
/* Adjust the provide heap start and size so that they are both aligned
@ -96,7 +96,7 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
heapend = MM_ALIGN_DOWN((uintptr_t)heapstart + (uintptr_t)heapsize);
heapsize = heapend - heapbase;
minfo("Region %d: base=%p size=%u\n", IDX+1, heapstart, heapsize);
minfo("Region %d: base=%p size=%u\n", IDX + 1, heapstart, heapsize);
/* Add the size of this region to the total size of the heap */
@ -114,11 +114,13 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
heap->mm_heapstart[IDX]->size = SIZEOF_MM_ALLOCNODE;
heap->mm_heapstart[IDX]->preceding = MM_ALLOC_BIT;
node = (FAR struct mm_freenode_s *)(heapbase + SIZEOF_MM_ALLOCNODE);
node = (FAR struct mm_freenode_s *)
(heapbase + SIZEOF_MM_ALLOCNODE);
node->size = heapsize - 2*SIZEOF_MM_ALLOCNODE;
node->preceding = SIZEOF_MM_ALLOCNODE;
heap->mm_heapend[IDX] = (FAR struct mm_allocnode_s *)(heapend - SIZEOF_MM_ALLOCNODE);
heap->mm_heapend[IDX] = (FAR struct mm_allocnode_s *)
(heapend - SIZEOF_MM_ALLOCNODE);
heap->mm_heapend[IDX]->size = SIZEOF_MM_ALLOCNODE;
heap->mm_heapend[IDX]->preceding = node->size | MM_ALLOC_BIT;
@ -182,8 +184,8 @@ void mm_initialize(FAR struct mm_heap_s *heap, FAR void *heapstart,
memset(heap->mm_nodelist, 0, sizeof(struct mm_freenode_s) * MM_NNODES);
for (i = 1; i < MM_NNODES; i++)
{
heap->mm_nodelist[i-1].flink = &heap->mm_nodelist[i];
heap->mm_nodelist[i].blink = &heap->mm_nodelist[i-1];
heap->mm_nodelist[i - 1].flink = &heap->mm_nodelist[i];
heap->mm_nodelist[i].blink = &heap->mm_nodelist[i - 1];
}
/* Initialize the malloc semaphore to one (to support one-at-

View File

@ -100,7 +100,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
if (alignsize >= MM_MAX_CHUNK)
{
ndx = MM_NNODES-1;
ndx = MM_NNODES - 1;
}
else
{
@ -188,7 +188,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
#ifdef CONFIG_MM_FILL_ALLOCATIONS
if (ret)
{
memset(ret, 0xAA, alignsize - SIZEOF_MM_ALLOCNODE);
memset(ret, 0xaa, alignsize - SIZEOF_MM_ALLOCNODE);
}
#endif

View File

@ -135,7 +135,8 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment,
DEBUGASSERT(alignedchunk >= rawchunk + 8);
newnode = (FAR struct mm_allocnode_s *)(alignedchunk - SIZEOF_MM_ALLOCNODE);
newnode = (FAR struct mm_allocnode_s *)
(alignedchunk - SIZEOF_MM_ALLOCNODE);
/* Preceding size is full size of the new 'node,' including
* SIZEOF_MM_ALLOCNODE
@ -154,7 +155,8 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment,
if (precedingsize < SIZEOF_MM_FREENODE)
{
alignedchunk += alignment;
newnode = (FAR struct mm_allocnode_s *)(alignedchunk - SIZEOF_MM_ALLOCNODE);
newnode = (FAR struct mm_allocnode_s *)
(alignedchunk - SIZEOF_MM_ALLOCNODE);
precedingsize = (size_t)newnode - (size_t)node;
}

View File

@ -108,7 +108,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
/* Map the memory chunk into an allocated node structure */
oldnode = (FAR struct mm_allocnode_s *)((FAR char *)oldmem - SIZEOF_MM_ALLOCNODE);
oldnode = (FAR struct mm_allocnode_s *)
((FAR char *)oldmem - SIZEOF_MM_ALLOCNODE);
/* We need to hold the MM semaphore while we muck with the nodelist. */
@ -139,13 +140,15 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
* best decision
*/
next = (FAR struct mm_freenode_s *)((FAR char *)oldnode + oldnode->size);
next = (FAR struct mm_freenode_s *)
((FAR char *)oldnode + oldnode->size);
if ((next->preceding & MM_ALLOC_BIT) == 0)
{
nextsize = next->size;
}
prev = (FAR struct mm_freenode_s *)((FAR char *)oldnode - (oldnode->preceding & ~MM_ALLOC_BIT));
prev = (FAR struct mm_freenode_s *)
((FAR char *)oldnode - (oldnode->preceding & ~MM_ALLOC_BIT));
if ((prev->preceding & MM_ALLOC_BIT) == 0)
{
prevsize = prev->size;
@ -233,7 +236,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
/* Extend the node into the previous free chunk */
newnode = (FAR struct mm_allocnode_s *)((FAR char *)oldnode - takeprev);
newnode = (FAR struct mm_allocnode_s *)
((FAR char *)oldnode - takeprev);
/* Did we consume the entire preceding chunk? */
@ -246,7 +250,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
prev->size -= takeprev;
newnode->size = oldsize + takeprev;
newnode->preceding = prev->size | MM_ALLOC_BIT;
next->preceding = newnode->size | (next->preceding & MM_ALLOC_BIT);
next->preceding = newnode->size |
(next->preceding & MM_ALLOC_BIT);
/* Return the previous free node to the nodelist (with the new size) */
@ -258,7 +263,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
newnode->size += oldsize;
newnode->preceding |= MM_ALLOC_BIT;
next->preceding = newnode->size | (next->preceding & MM_ALLOC_BIT);
next->preceding = newnode->size |
(next->preceding & MM_ALLOC_BIT);
}
/* Now we want to return newnode */
@ -301,7 +307,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
/* Extend the node into the next chunk */
oldnode->size = oldsize + takenext;
newnode = (FAR struct mm_freenode_s *)((FAR char *)oldnode + oldnode->size);
newnode = (FAR struct mm_freenode_s *)
((FAR char *)oldnode + oldnode->size);
/* Did we consume the entire preceding chunk? */
@ -313,7 +320,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
newnode->size = nextsize - takenext;
newnode->preceding = oldnode->size;
andbeyond->preceding = newnode->size | (andbeyond->preceding & MM_ALLOC_BIT);
andbeyond->preceding = newnode->size |
(andbeyond->preceding & MM_ALLOC_BIT);
/* Add the new free node to the nodelist (with the new size) */
@ -323,7 +331,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
{
/* Yes, just update some pointers. */
andbeyond->preceding = oldnode->size | (andbeyond->preceding & MM_ALLOC_BIT);
andbeyond->preceding = oldnode->size |
(andbeyond->preceding & MM_ALLOC_BIT);
}
}

View File

@ -106,7 +106,8 @@ void mm_shrinkchunk(FAR struct mm_heap_s *heap,
newnode->size = next->size + node->size - size;
newnode->preceding = size;
node->size = size;
andbeyond->preceding = newnode->size | (andbeyond->preceding & MM_ALLOC_BIT);
andbeyond->preceding = newnode->size |
(andbeyond->preceding & MM_ALLOC_BIT);
/* Add the new node to the freenodelist */

View File

@ -59,7 +59,7 @@ int mm_size2ndx(size_t size)
if (size >= MM_MAX_CHUNK)
{
return MM_NNODES-1;
return MM_NNODES - 1;
}
size >>= MM_MIN_SHIFT;

View File

@ -66,3 +66,7 @@
struct mm_heap_s g_mmheap;
#endif
/****************************************************************************
* Public Functions
****************************************************************************/