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
+3 -3
View File
@@ -132,9 +132,9 @@ static FAR struct iob_qentry_s *iob_allocwait_qentry(void)
ret = nxsem_wait_uninterruptible(&g_qentry_sem); ret = nxsem_wait_uninterruptible(&g_qentry_sem);
if (ret >= 0) if (ret >= 0)
{ {
/* When we wake up from wait successfully, an I/O buffer chain container was /* When we wake up from wait successfully, an I/O buffer chain
* freed and we hold a count for one IOB. Unless somehting * container was freed and we hold a count for one IOB. Unless
* failed, we should have an IOB waiting for us in the * something failed, we should have an IOB waiting for us in the
* committed list. * committed list.
*/ */
+2 -1
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, unsigned int len, unsigned int offset, bool throttled,
enum iob_user_e consumerid) 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);
} }
+2 -1
View File
@@ -169,7 +169,8 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob,
#if CONFIG_IOB_THROTTLE > 0 #if CONFIG_IOB_THROTTLE > 0
nxsem_post(&g_throttle_sem); 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 #endif
#ifdef CONFIG_IOB_NOTIFIER #ifdef CONFIG_IOB_NOTIFIER
+1
View File
@@ -78,6 +78,7 @@ int iob_navail(bool throttled)
ret -= CONFIG_IOB_THROTTLE; ret -= CONFIG_IOB_THROTTLE;
} }
#endif #endif
if (ret < 0) if (ret < 0)
{ {
ret = 0; ret = 0;
-1
View File
@@ -107,7 +107,6 @@ void iob_stats_onfree(enum iob_user_e producerid)
/* Increment the global statistic as well */ /* Increment the global statistic as well */
g_iobuserstats[IOBUSER_GLOBAL].totalproduced++; g_iobuserstats[IOBUSER_GLOBAL].totalproduced++;
} }
/**************************************************************************** /****************************************************************************
+1
View File
@@ -115,6 +115,7 @@ int main(int argc, char **argv)
{ {
buffer1[i] = (uint8_t)(i & 0xff); buffer1[i] = (uint8_t)(i & 0xff);
} }
memset(buffer2, 0xff, 4096); memset(buffer2, 0xff, 4096);
iob_copyin(iob, buffer2, 47, 0, false, IOBUSER_UNITTEST); iob_copyin(iob, buffer2, 47, 0, false, IOBUSER_UNITTEST);
+2 -1
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 /* 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) else if ((curr & mask) == 0)
-1
View File
@@ -86,5 +86,4 @@ void gran_leave_critical(FAR struct gran_s *priv)
#endif #endif
} }
#endif /* CONFIG_GRAN */ #endif /* CONFIG_GRAN */
+2
View File
@@ -51,7 +51,9 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/* CONFIG_MM_PGALLOC - Enable page allocator support /* CONFIG_MM_PGALLOC - Enable page allocator support
* CONFIG_MM_PGSIZE - The page size. Must be one of {1024, 2048, * CONFIG_MM_PGSIZE - The page size. Must be one of {1024, 2048,
* 4096, 8192, or 16384}. This is easily extensible, but only those * 4096, 8192, or 16384}. This is easily extensible, but only those
+2 -1
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 */ /* 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->size = SIZEOF_MM_ALLOCNODE;
newnode->preceding = oldnode->size | MM_ALLOC_BIT; newnode->preceding = oldnode->size | MM_ALLOC_BIT;
+4 -2
View File
@@ -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]->size = SIZEOF_MM_ALLOCNODE;
heap->mm_heapstart[IDX]->preceding = MM_ALLOC_BIT; 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->size = heapsize - 2*SIZEOF_MM_ALLOCNODE;
node->preceding = 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]->size = SIZEOF_MM_ALLOCNODE;
heap->mm_heapend[IDX]->preceding = node->size | MM_ALLOC_BIT; heap->mm_heapend[IDX]->preceding = node->size | MM_ALLOC_BIT;
+1 -1
View File
@@ -188,7 +188,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
#ifdef CONFIG_MM_FILL_ALLOCATIONS #ifdef CONFIG_MM_FILL_ALLOCATIONS
if (ret) if (ret)
{ {
memset(ret, 0xAA, alignsize - SIZEOF_MM_ALLOCNODE); memset(ret, 0xaa, alignsize - SIZEOF_MM_ALLOCNODE);
} }
#endif #endif
+4 -2
View File
@@ -135,7 +135,8 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment,
DEBUGASSERT(alignedchunk >= rawchunk + 8); 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 /* Preceding size is full size of the new 'node,' including
* SIZEOF_MM_ALLOCNODE * 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) if (precedingsize < SIZEOF_MM_FREENODE)
{ {
alignedchunk += alignment; 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; precedingsize = (size_t)newnode - (size_t)node;
} }
+18 -9
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 */ /* 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. */ /* 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 * 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) if ((next->preceding & MM_ALLOC_BIT) == 0)
{ {
nextsize = next->size; 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) if ((prev->preceding & MM_ALLOC_BIT) == 0)
{ {
prevsize = prev->size; 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 */ /* 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? */ /* 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; prev->size -= takeprev;
newnode->size = oldsize + takeprev; newnode->size = oldsize + takeprev;
newnode->preceding = prev->size | MM_ALLOC_BIT; 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) */ /* 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->size += oldsize;
newnode->preceding |= MM_ALLOC_BIT; 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 */ /* 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 */ /* Extend the node into the next chunk */
oldnode->size = oldsize + takenext; 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? */ /* 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->size = nextsize - takenext;
newnode->preceding = oldnode->size; 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) */ /* 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. */ /* Yes, just update some pointers. */
andbeyond->preceding = oldnode->size | (andbeyond->preceding & MM_ALLOC_BIT); andbeyond->preceding = oldnode->size |
(andbeyond->preceding & MM_ALLOC_BIT);
} }
} }
+2 -1
View File
@@ -106,7 +106,8 @@ void mm_shrinkchunk(FAR struct mm_heap_s *heap,
newnode->size = next->size + node->size - size; newnode->size = next->size + node->size - size;
newnode->preceding = size; newnode->preceding = size;
node->size = 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 */ /* Add the new node to the freenodelist */
+4
View File
@@ -66,3 +66,7 @@
struct mm_heap_s g_mmheap; struct mm_heap_s g_mmheap;
#endif #endif
/****************************************************************************
* Public Functions
****************************************************************************/