Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2333df5

Browse filesBrowse files
authored
Removes a few Warnings and fixes Math rand() to work like Arduino mainstream (espressif#7613)
* fixes warnings and rand function * removes extra space - style
1 parent 5dff15c commit 2333df5
Copy full SHA for 2333df5

File tree

Expand file treeCollapse file tree

7 files changed

+30
-38
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+30
-38
lines changed

‎cores/esp32/Print.cpp

Copy file name to clipboardExpand all lines: cores/esp32/Print.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ size_t Print::printf(const char *format, ...)
5858
va_end(arg);
5959
return 0;
6060
};
61-
if(len >= sizeof(loc_buf)){
61+
if(len >= (int)sizeof(loc_buf)){ // comparation of same sign type for the compiler
6262
temp = (char*) malloc(len+1);
6363
if(temp == NULL) {
6464
va_end(arg);

‎cores/esp32/WMath.cpp

Copy file name to clipboardExpand all lines: cores/esp32/WMath.cpp
+10-18Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,17 @@ void randomSeed(unsigned long seed)
3636
}
3737
}
3838

39-
long random(long howbig)
39+
long random( long howsmall, long howbig );
40+
long random( long howbig )
4041
{
41-
uint32_t x = esp_random();
42-
uint64_t m = uint64_t(x) * uint64_t(howbig);
43-
uint32_t l = uint32_t(m);
44-
if (l < howbig) {
45-
uint32_t t = -howbig;
46-
if (t >= howbig) {
47-
t -= howbig;
48-
if (t >= howbig)
49-
t %= howbig;
50-
}
51-
while (l < t) {
52-
x = esp_random();
53-
m = uint64_t(x) * uint64_t(howbig);
54-
l = uint32_t(m);
55-
}
56-
}
57-
return m >> 32;
42+
if ( howbig == 0 )
43+
{
44+
return 0 ;
45+
}
46+
if (howbig < 0) {
47+
return (random(0, -howbig));
48+
}
49+
return esp_random() % howbig;
5850
}
5951

6052
long random(long howsmall, long howbig)

‎cores/esp32/esp32-hal-rmt.c

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-rmt.c
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ struct rmt_obj_s
8888
{
8989
bool allocated;
9090
EventGroupHandle_t events;
91-
int channel;
92-
int buffers;
93-
int data_size;
91+
uint32_t channel;
92+
uint32_t buffers;
93+
uint32_t data_size;
9494
uint32_t* data_ptr;
9595
rmt_rx_data_cb_t cb;
9696
void * arg;
@@ -133,7 +133,7 @@ static xSemaphoreHandle g_rmt_block_lock = NULL;
133133

134134
static rmt_obj_t* _rmtAllocate(int pin, int from, int size)
135135
{
136-
size_t i;
136+
int i;
137137
// setup how many buffers shall we use
138138
g_rmt_objects[from].buffers = size;
139139

@@ -539,10 +539,10 @@ float rmtSetTick(rmt_obj_t* rmt, float tick)
539539

540540
rmt_obj_t* rmtInit(int pin, bool tx_not_rx, rmt_reserve_memsize_t memsize)
541541
{
542-
int buffers = memsize;
542+
uint32_t buffers = memsize;
543543
rmt_obj_t* rmt = NULL;
544-
size_t i = 0;
545-
size_t j = 0;
544+
uint32_t i = 0;
545+
uint32_t j = 0;
546546

547547
// create common block mutex for protecting allocs from multiple threads
548548
if (!g_rmt_block_lock) {

‎cores/esp32/esp32-hal-spi.c

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-spi.c
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ static void __spiTransferBytes(spi_t * spi, const uint8_t * data, uint8_t * out,
10031003
if(!spi) {
10041004
return;
10051005
}
1006-
int i;
1006+
uint32_t i;
10071007

10081008
if(bytes > 64) {
10091009
bytes = 64;
@@ -1298,7 +1298,7 @@ void spiWriteNL(spi_t * spi, const void * data_in, uint32_t len){
12981298
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
12991299
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
13001300
#endif
1301-
for (int i=0; i<c_longs; i++) {
1301+
for (size_t i=0; i<c_longs; i++) {
13021302
spi->dev->data_buf[i] = data[i];
13031303
}
13041304
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
@@ -1333,11 +1333,11 @@ void spiTransferBytesNL(spi_t * spi, const void * data_in, uint8_t * data_out, u
13331333
spi->dev->mosi_dlen.usr_mosi_dbitlen = (c_len*8)-1;
13341334
spi->dev->miso_dlen.usr_miso_dbitlen = (c_len*8)-1;
13351335
if(data){
1336-
for (int i=0; i<c_longs; i++) {
1336+
for (size_t i=0; i<c_longs; i++) {
13371337
spi->dev->data_buf[i] = data[i];
13381338
}
13391339
} else {
1340-
for (int i=0; i<c_longs; i++) {
1340+
for (size_t i=0; i<c_longs; i++) {
13411341
spi->dev->data_buf[i] = 0xFFFFFFFF;
13421342
}
13431343
}
@@ -1349,17 +1349,17 @@ void spiTransferBytesNL(spi_t * spi, const void * data_in, uint8_t * data_out, u
13491349
while(spi->dev->cmd.usr);
13501350
if(result){
13511351
if(c_len & 3){
1352-
for (int i=0; i<(c_longs-1); i++) {
1352+
for (size_t i=0; i<(c_longs-1); i++) {
13531353
result[i] = spi->dev->data_buf[i];
13541354
}
13551355
uint32_t last_data = spi->dev->data_buf[c_longs-1];
13561356
uint8_t * last_out8 = (uint8_t *)&result[c_longs-1];
13571357
uint8_t * last_data8 = (uint8_t *)&last_data;
1358-
for (int i=0; i<(c_len & 3); i++) {
1358+
for (size_t i=0; i<(c_len & 3); i++) {
13591359
last_out8[i] = last_data8[i];
13601360
}
13611361
} else {
1362-
for (int i=0; i<c_longs; i++) {
1362+
for (size_t i=0; i<c_longs; i++) {
13631363
result[i] = spi->dev->data_buf[i];
13641364
}
13651365
}
@@ -1439,7 +1439,7 @@ void ARDUINO_ISR_ATTR spiWritePixelsNL(spi_t * spi, const void * data_in, uint32
14391439
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
14401440
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
14411441
#endif
1442-
for (int i=0; i<c_longs; i++) {
1442+
for (size_t i=0; i<c_longs; i++) {
14431443
if(msb){
14441444
if(l_bytes && i == (c_longs - 1)){
14451445
if(l_bytes == 2){

‎cores/esp32/esp32-hal-timer.c

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-timer.c
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static hw_timer_t timer_dev[4] = {
4747
// timer_init() will list thru all timers and return free timer handle)
4848

4949

50-
uint64_t inline timerRead(hw_timer_t *timer){
50+
inline uint64_t timerRead(hw_timer_t *timer){
5151

5252
uint64_t value;
5353
timer_get_counter_value(timer->group, timer->num,&value);

‎cores/esp32/esp32-hal-uart.c

Copy file name to clipboardExpand all lines: cores/esp32/esp32-hal-uart.c
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ int log_printfv(const char *format, va_list arg)
537537
{
538538
static char loc_buf[64];
539539
char * temp = loc_buf;
540-
int len;
540+
uint32_t len;
541541
va_list copy;
542542
va_copy(copy, arg);
543543
len = vsnprintf(NULL, 0, format, copy);

‎cores/esp32/stdlib_noniso.c

Copy file name to clipboardExpand all lines: cores/esp32/stdlib_noniso.c
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,15 @@ char * dtostrf(double number, signed int width, unsigned int prec, char *s) {
163163
// Round correctly so that print(1.999, 2) prints as "2.00"
164164
// I optimized out most of the divisions
165165
double rounding = 2.0;
166-
for (uint32_t i = 0; i < prec; ++i)
166+
for (unsigned int i = 0; i < prec; ++i)
167167
rounding *= 10.0;
168168
rounding = 1.0 / rounding;
169169

170170
number += rounding;
171171

172172
// Figure out how big our number really is
173173
double tenpow = 1.0;
174-
int digitcount = 1;
174+
unsigned int digitcount = 1;
175175
while (number >= 10.0 * tenpow) {
176176
tenpow *= 10.0;
177177
digitcount++;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.