Skip to content

Commit 32b7f4d

Browse files
committed
removed static variables from function bodies
1 parent acb5ded commit 32b7f4d

File tree

20 files changed

+36
-44
lines changed

20 files changed

+36
-44
lines changed

STM32F1/cores/maple/WString.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,10 @@ void String::setCharAt(unsigned int loc, char c)
520520
if (loc < len) buffer[loc] = c;
521521
}
522522

523+
static char dummy_writable_char = 0;
523524
char & String::operator[](unsigned int index)
524525
{
525-
static char dummy_writable_char;
526526
if (index >= len || !buffer) {
527-
dummy_writable_char = 0;
528527
return dummy_writable_char;
529528
}
530529
return buffer[index];

STM32F1/cores/maple/libmaple/syscalls.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,15 @@ extern char _lm_heap_end;
5151
#define CONFIG_HEAP_END ((void *)&_lm_heap_end)
5252
#endif
5353

54+
static void * pbreak = NULL; /* current program break */
5455
/*
5556
* _sbrk -- Increment the program break.
5657
*
5758
* Get incr bytes more RAM (for use by the heap). malloc() and
5859
* friends call this function behind the scenes.
5960
*/
60-
void *_sbrk(int incr) {
61-
static void * pbreak = NULL; /* current program break */
62-
void * ret;
63-
61+
void *_sbrk(int incr)
62+
{
6463
if (pbreak == NULL) {
6564
pbreak = CONFIG_HEAP_START;
6665
}
@@ -71,7 +70,7 @@ void *_sbrk(int incr) {
7170
return (void *)-1;
7271
}
7372

74-
ret = pbreak;
73+
void * ret = pbreak;
7574
pbreak += incr;
7675
return ret;
7776
}

STM32F1/libraries/Adafruit_SSD1306/Adafruit_SSD1306_STM32.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,9 @@ void Adafruit_SSD1306::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t c
665665
}
666666
}
667667

668-
668+
static uint8_t premask[8] = {0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE };
669+
static uint8_t postmask[8] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F };
670+
//------------------------------------------------------------------------------
669671
void Adafruit_SSD1306::drawFastVLineInternal(int16_t x, int16_t __y, int16_t __h, uint16_t color) {
670672

671673
// do nothing if we're off the left or right side of the screen
@@ -709,7 +711,6 @@ void Adafruit_SSD1306::drawFastVLineInternal(int16_t x, int16_t __y, int16_t __h
709711

710712
// note - lookup table results in a nearly 10% performance improvement in fill* functions
711713
// register uint8_t mask = ~(0xFF >> (mod));
712-
static uint8_t premask[8] = {0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE };
713714
register uint8_t mask = premask[mod];
714715

715716
// adjust the mask if we're not going to reach the end of this byte
@@ -769,7 +770,6 @@ void Adafruit_SSD1306::drawFastVLineInternal(int16_t x, int16_t __y, int16_t __h
769770
// this time we want to mask the low bits of the byte, vs the high bits we did above
770771
// register uint8_t mask = (1 << mod) - 1;
771772
// note - lookup table results in a nearly 10% performance improvement in fill* functions
772-
static uint8_t postmask[8] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F };
773773
register uint8_t mask = postmask[mod];
774774
switch (color)
775775
{

STM32F1/libraries/FreeRTOS10/MapleFreeRTOS10.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
extern "C" {
3030

31+
static StaticTask_t xIdleTaskTCB;
32+
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
3133
//-----------------------------------------------------------------------------
3234
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
3335
* implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
@@ -40,8 +42,6 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
4042
/* If the buffers to be provided to the Idle task are declared inside this
4143
* function then they must be declared static - otherwise they will be allocated on
4244
* the stack and so not exists after this function exits. */
43-
static StaticTask_t xIdleTaskTCB;
44-
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
4545

4646
/* Pass out a pointer to the StaticTask_t structure in which the Idle task's
4747
* state will be stored. */
@@ -87,6 +87,7 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask,
8787

8888
#if 0
8989
StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
90+
static StaticTask_t xTimerTaskTCB;
9091
//-----------------------------------------------------------------------------
9192
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
9293
StackType_t ** ppxTimerTaskStackBuffer,
@@ -95,7 +96,6 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
9596
/* If the buffers to be provided to the Timer task are declared inside this
9697
* function then they must be declared static - otherwise they will be allocated on
9798
* the stack and so not exists after this function exits. */
98-
static StaticTask_t xTimerTaskTCB;
9999

100100
/* Pass out a pointer to the StaticTask_t structure in which the Timer
101101
* task's state will be stored. */

STM32F1/libraries/FreeRTOS10/utility/MemMang/heap_1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@
6767
static size_t xNextFreeByte = ( size_t ) 0;
6868

6969
/*-----------------------------------------------------------*/
70+
static uint8_t * pucAlignedHeap = NULL;
7071

7172
void * pvPortMalloc( size_t xWantedSize )
7273
{
7374
void * pvReturn = NULL;
74-
static uint8_t * pucAlignedHeap = NULL;
7575

7676
/* Ensure that blocks are always aligned. */
7777
#if ( portBYTE_ALIGNMENT != 1 )

STM32F1/libraries/FreeRTOS10/utility/MemMang/heap_2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ static void prvHeapInit( void ) PRIVILEGED_FUNCTION;
149149
pxIterator->pxNextFreeBlock = pxBlockToInsert; \
150150
}
151151
/*-----------------------------------------------------------*/
152+
PRIVILEGED_DATA static BaseType_t xHeapHasBeenInitialised = pdFALSE;
152153

153154
void * pvPortMalloc( size_t xWantedSize )
154155
{
155156
BlockLink_t * pxBlock;
156157
BlockLink_t * pxPreviousBlock;
157158
BlockLink_t * pxNewBlockLink;
158-
PRIVILEGED_DATA static BaseType_t xHeapHasBeenInitialised = pdFALSE;
159159
void * pvReturn = NULL;
160160
size_t xAdditionalRequiredSize;
161161

STM32F1/libraries/FreeRTOS10/utility/timers.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,11 @@
689689
return xNextExpireTime;
690690
}
691691
/*-----------------------------------------------------------*/
692+
PRIVILEGED_DATA static TickType_t xLastTime = ( TickType_t ) 0U; /*lint !e956 Variable is only accessible to one task. */
692693

693694
static TickType_t prvSampleTimeNow( BaseType_t * const pxTimerListsWereSwitched )
694695
{
695696
TickType_t xTimeNow;
696-
PRIVILEGED_DATA static TickType_t xLastTime = ( TickType_t ) 0U; /*lint !e956 Variable is only accessible to one task. */
697697

698698
xTimeNow = xTaskGetTickCount();
699699

@@ -929,6 +929,8 @@
929929
pxOverflowTimerList = pxTemp;
930930
}
931931
/*-----------------------------------------------------------*/
932+
PRIVILEGED_DATA static StaticQueue_t xStaticTimerQueue; /*lint !e956 Ok to declare in this manner to prevent additional conditional compilation guards in other locations. */
933+
PRIVILEGED_DATA static uint8_t ucStaticTimerQueueStorage[ ( size_t ) configTIMER_QUEUE_LENGTH * sizeof( DaemonTaskMessage_t ) ]; /*lint !e956 Ok to declare in this manner to prevent additional conditional compilation guards in other locations. */
932934

933935
static void prvCheckForValidListAndQueue( void )
934936
{
@@ -948,8 +950,6 @@
948950
{
949951
/* The timer queue is allocated statically in case
950952
* configSUPPORT_DYNAMIC_ALLOCATION is 0. */
951-
PRIVILEGED_DATA static StaticQueue_t xStaticTimerQueue; /*lint !e956 Ok to declare in this manner to prevent additional conditional compilation guards in other locations. */
952-
PRIVILEGED_DATA static uint8_t ucStaticTimerQueueStorage[ ( size_t ) configTIMER_QUEUE_LENGTH * sizeof( DaemonTaskMessage_t ) ]; /*lint !e956 Ok to declare in this manner to prevent additional conditional compilation guards in other locations. */
953953

954954
xTimerQueue = xQueueCreateStatic( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, ( UBaseType_t ) sizeof( DaemonTaskMessage_t ), &( ucStaticTimerQueueStorage[ 0 ] ), &xStaticTimerQueue );
955955
}

STM32F1/libraries/FreeRTOS701/utility/heap_2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ xBlockLink *pxFirstFreeBlock; \
150150
pxFirstFreeBlock->pxNextFreeBlock = &xEnd; \
151151
}
152152
/*-----------------------------------------------------------*/
153+
static portBASE_TYPE xHeapHasBeenInitialised = pdFALSE;
153154

154155
void *pvPortMalloc( size_t xWantedSize )
155156
{
156157
xBlockLink *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
157-
static portBASE_TYPE xHeapHasBeenInitialised = pdFALSE;
158158
void *pvReturn = NULL;
159159

160160
vTaskSuspendAll();

STM32F1/libraries/FreeRTOS701/utility/timers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,11 @@ portTickType xNextExpireTime;
401401
return xNextExpireTime;
402402
}
403403
/*-----------------------------------------------------------*/
404+
static portTickType xLastTime = ( portTickType ) 0U;
404405

405406
static portTickType prvSampleTimeNow( portBASE_TYPE *pxTimerListsWereSwitched )
406407
{
407408
portTickType xTimeNow;
408-
static portTickType xLastTime = ( portTickType ) 0U;
409409

410410
xTimeNow = xTaskGetTickCount();
411411

STM32F1/libraries/FreeRTOS821/utility/MemMang/heap_1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ task.h is included from an application file. */
9494
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
9595
static size_t xNextFreeByte = ( size_t ) 0;
9696

97+
static uint8_t *pucAlignedHeap = NULL;
9798
/*-----------------------------------------------------------*/
9899

99100
void *pvPortMalloc( size_t xWantedSize )
100101
{
101102
void *pvReturn = NULL;
102-
static uint8_t *pucAlignedHeap = NULL;
103103

104104
/* Ensure that blocks are always aligned to the required number of bytes. */
105105
#if portBYTE_ALIGNMENT != 1

STM32F1/libraries/FreeRTOS821/utility/MemMang/heap_2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ size_t xBlockSize; \
145145
pxIterator->pxNextFreeBlock = pxBlockToInsert; \
146146
}
147147
/*-----------------------------------------------------------*/
148+
static BaseType_t xHeapHasBeenInitialised = pdFALSE;
148149

149150
void *pvPortMalloc( size_t xWantedSize )
150151
{
151152
BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
152-
static BaseType_t xHeapHasBeenInitialised = pdFALSE;
153153
void *pvReturn = NULL;
154154

155155
vTaskSuspendAll();

STM32F1/libraries/FreeRTOS821/utility/heap_1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ task.h is included from an application file. */
9494
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
9595
static size_t xNextFreeByte = ( size_t ) 0;
9696

97+
static uint8_t *pucAlignedHeap = NULL;
9798
/*-----------------------------------------------------------*/
9899

99100
void *pvPortMalloc( size_t xWantedSize )
100101
{
101102
void *pvReturn = NULL;
102-
static uint8_t *pucAlignedHeap = NULL;
103103

104104
/* Ensure that blocks are always aligned to the required number of bytes. */
105105
#if portBYTE_ALIGNMENT != 1

STM32F1/libraries/FreeRTOS821/utility/timers.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,11 @@ TickType_t xNextExpireTime;
517517
return xNextExpireTime;
518518
}
519519
/*-----------------------------------------------------------*/
520+
PRIVILEGED_DATA static TickType_t xLastTime = ( TickType_t ) 0U; /*lint !e956 Variable is only accessible to one task. */
520521

521522
static TickType_t prvSampleTimeNow( BaseType_t * const pxTimerListsWereSwitched )
522523
{
523-
TickType_t xTimeNow;
524-
PRIVILEGED_DATA static TickType_t xLastTime = ( TickType_t ) 0U; /*lint !e956 Variable is only accessible to one task. */
525-
526-
xTimeNow = xTaskGetTickCount();
524+
TickType_t xTimeNow = xTaskGetTickCount();
527525

528526
if( xTimeNow < xLastTime )
529527
{

STM32F1/libraries/FreeRTOS900/utility/MemMang/heap_1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ task.h is included from an application file. */
9393
/* Allocate the memory for the heap. */
9494
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
9595
static size_t xNextFreeByte = ( size_t ) 0;
96+
static uint8_t *pucAlignedHeap = NULL;
9697

9798
/*-----------------------------------------------------------*/
9899

99100
void *pvPortMalloc( size_t xWantedSize )
100101
{
101102
void *pvReturn = NULL;
102-
static uint8_t *pucAlignedHeap = NULL;
103103

104104
/* Ensure that blocks are always aligned to the required number of bytes. */
105105
#if portBYTE_ALIGNMENT != 1

STM32F1/libraries/FreeRTOS900/utility/MemMang/heap_2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ size_t xBlockSize; \
145145
pxIterator->pxNextFreeBlock = pxBlockToInsert; \
146146
}
147147
/*-----------------------------------------------------------*/
148+
static BaseType_t xHeapHasBeenInitialised = pdFALSE;
148149

149150
void *pvPortMalloc( size_t xWantedSize )
150151
{
151152
BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
152-
static BaseType_t xHeapHasBeenInitialised = pdFALSE;
153153
void *pvReturn = NULL;
154154

155155
vTaskSuspendAll();

STM32F1/libraries/FreeRTOS900/utility/heap_1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ task.h is included from an application file. */
9393
/* Allocate the memory for the heap. */
9494
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
9595
static size_t xNextFreeByte = ( size_t ) 0;
96+
static uint8_t *pucAlignedHeap = NULL;
9697

9798
/*-----------------------------------------------------------*/
9899

99100
void *pvPortMalloc( size_t xWantedSize )
100101
{
101102
void *pvReturn = NULL;
102-
static uint8_t *pucAlignedHeap = NULL;
103103

104104
/* Ensure that blocks are always aligned to the required number of bytes. */
105105
#if portBYTE_ALIGNMENT != 1

STM32F1/libraries/FreeRTOS900/utility/timers.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -656,13 +656,11 @@ TickType_t xNextExpireTime;
656656
return xNextExpireTime;
657657
}
658658
/*-----------------------------------------------------------*/
659+
PRIVILEGED_DATA static TickType_t xLastTime = ( TickType_t ) 0U; /*lint !e956 Variable is only accessible to one task. */
659660

660661
static TickType_t prvSampleTimeNow( BaseType_t * const pxTimerListsWereSwitched )
661662
{
662-
TickType_t xTimeNow;
663-
PRIVILEGED_DATA static TickType_t xLastTime = ( TickType_t ) 0U; /*lint !e956 Variable is only accessible to one task. */
664-
665-
xTimeNow = xTaskGetTickCount();
663+
TickType_t xTimeNow = xTaskGetTickCount();
666664

667665
if( xTimeNow < xLastTime )
668666
{
@@ -926,6 +924,8 @@ BaseType_t xResult;
926924
pxOverflowTimerList = pxTemp;
927925
}
928926
/*-----------------------------------------------------------*/
927+
static StaticQueue_t xStaticTimerQueue;
928+
static uint8_t ucStaticTimerQueueStorage[ configTIMER_QUEUE_LENGTH * sizeof( DaemonTaskMessage_t ) ];
929929

930930
static void prvCheckForValidListAndQueue( void )
931931
{
@@ -945,8 +945,6 @@ static void prvCheckForValidListAndQueue( void )
945945
{
946946
/* The timer queue is allocated statically in case
947947
configSUPPORT_DYNAMIC_ALLOCATION is 0. */
948-
static StaticQueue_t xStaticTimerQueue;
949-
static uint8_t ucStaticTimerQueueStorage[ configTIMER_QUEUE_LENGTH * sizeof( DaemonTaskMessage_t ) ];
950948

951949
xTimerQueue = xQueueCreateStatic( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, sizeof( DaemonTaskMessage_t ), &( ucStaticTimerQueueStorage[ 0 ] ), &xStaticTimerQueue );
952950
}

STM32F1/libraries/Lcd7920_STM/examples/Lcd7920_STM/Lcd7920_STM.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ void setup()
3333
lcd.textInvert(0);
3434
}
3535

36+
static byte counter = 0;
3637
void loop()
3738
{
38-
static byte counter = 0;
39-
//
4039
counter++;
4140
if (counter > 128)
4241
{

STM32F1/libraries/Serasidis_EtherCard_STM/src/dhcp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ static void addBytes (byte len, const byte* data) {
150150
// 58 Renewal (T1) Time Value
151151
// 61 Client-identifier
152152
// 255 End
153+
static byte cookie[] = { 99, 130, 83, 99, 53, 1 };
153154

154155
static void send_dhcp_message (void) {
155156

@@ -178,7 +179,6 @@ static void send_dhcp_message (void) {
178179
// options defined as option, length, value
179180
bufPtr = gPB + UDP_DATA_P + sizeof( DHCPdata );
180181
// DHCP magic cookie, followed by message type
181-
static byte cookie[] = { 99, 130, 83, 99, 53, 1 };
182182
addBytes(sizeof cookie, cookie);
183183
// addToBuf(53); // DHCP_STATE_SELECTING, DHCP_STATE_REQUESTING
184184
// addToBuf(1); // Length

STM32F1/variants/generic_stm32f103vb/wirish/syscalls.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,15 @@ extern char _lm_heap_end;
5151
#define CONFIG_HEAP_END ((void *)&_lm_heap_end)
5252
#endif
5353

54+
static void * pbreak = NULL; /* current program break */
5455
/*
5556
* _sbrk -- Increment the program break.
5657
*
5758
* Get incr bytes more RAM (for use by the heap). malloc() and
5859
* friends call this function behind the scenes.
5960
*/
60-
void *_sbrk(int incr) {
61-
static void * pbreak = NULL; /* current program break */
62-
void * ret;
63-
61+
void *_sbrk(int incr)
62+
{
6463
if (pbreak == NULL) {
6564
pbreak = CONFIG_HEAP_START;
6665
}
@@ -71,7 +70,7 @@ void *_sbrk(int incr) {
7170
return (void *)-1;
7271
}
7372

74-
ret = pbreak;
73+
void * ret = pbreak;
7574
pbreak += incr;
7675
return ret;
7776
}

0 commit comments

Comments
 (0)