ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
333 stars 133 forks source link

Missing "return value" #173

Open J-Lacerte opened 3 years ago

J-Lacerte commented 3 years ago

In the "MySQL_Encrypt_Sha1.cpp" file of the "MySQL_Connector_Arduino" library, there are two functions:

ChuckBell commented 2 years ago

I am aware this can generate a warning (that can be turned off), but can you confirm by ‘exception’ you mean the code crashes or do you mean “generates a warning”?

On Jul 15, 2021, at 8:49 PM, J-Lacerte @.***> wrote:

In the "MySQL_Encrypt_Sha1.cpp" file of the "MySQL_Connector_Arduino" library, there are two functions:

size_t Encrypt_SHA1 :: write (uint8_t data) {...} size_t Encrypt_SHA1 :: write (uint8_t * data, int length) {...} according to their definition, they should make a "return" of a value of type "size_t" but neither one has a "return" which causes in my Windows 10 environment an exception. To be able to use this library, I added to these functions a "return -1;" Is it possible to correct this problem. Thank you — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/173, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYAPTD642B26L52HOU3TX56ZJANCNFSM5AOSWPNQ.

J-Lacerte commented 2 years ago

Bonjour,

Unfortunately, this throws an exception and the program crashes:

Merci,

J.Lacerte

Exception Decoder :

Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads PC: 0x402024d8 EXCVADDR: 0x00000049

Decoding stack results 0x4020252b: Encrypt_SHA1::pad() at C:\Users\Jacques\Documents\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Encrypt_Sha1.cpp line 102 0x40100140: ets_intr_unlock() at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 167 0x40202518: Encrypt_SHA1::pad() at C:\Users\Jacques\Documents\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Encrypt_Sha1.cpp line 101 0x40206678: Print::write(unsigned char const, unsigned int) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\Print.cpp line 41 0x40206644: Print::write(unsigned char const, unsigned int) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\Print.cpp line 35 0x40202e74: Print::write(char const) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/Print.h line 59 0x40202e98: Print::write(char const) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/Print.h line 57 0x40202ff4: Print::print(char const) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\Print.cpp line 121 0x402028e7: MySQL_Packet::scramble_password(char, unsigned char) at C:\Users\Jacques\Documents\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Packet.cpp line 191 0x40100209: millis() at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_wiring.cpp line 193 0x402150da: ip4_output_if at core/ipv4/ip4.c line 1549 0x401006c3: umm_free_core(umm_heap_context_t, void) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 549 0x401008a2: free(void) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 595 0x40100298: vPortFree(void, char const, int) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\heap.cpp line 322 0x40215b40: mem_free at core/mem.c line 236 0x401006c3: umm_free_core(umm_heap_context_t, void) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\umm_malloc\umm_malloc.cpp line 549 0x40202a2a: MySQL_Packet::send_authentication_packet(char, char, char) at C:\Users\Jacques\Documents\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Packet.cpp line 135 0x4020279a: MySQL_Packet::parse_handshake_packet() at C:\Users\Jacques\Documents\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Packet.cpp line 352 0x40202312: MySQL_Connection::connect(IPAddress, int, char, char, char) at C:\Users\Jacques\Documents\Arduino\libraries\MySQL_Connector_Arduino\src\MySQL_Connection.cpp line 88 0x40202c00: HardwareSerial::write(unsigned char const*, unsigned int) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/HardwareSerial.h line 193 0x4020206c: WiFiClient::connect(IPAddress, unsigned short) at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\WiFiClient.cpp line 145 0x40203024: Print::println() at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/Print.h line 57 0x402011d0: setup() at C:\Users\Jacques\Documents\Arduino\sketch_jul08c/sketch_jul08c.ino line 56 0x40203b98: loop_wrapper() at C:\Users\Jacques\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 198

De : Dr. Charles Bell @.> Envoyé : 18 juillet 2021 15:19 À : ChuckBell/MySQL_Connector_Arduino @.> Cc : J-Lacerte @.>; Author @.> Objet : Re: [ChuckBell/MySQL_Connector_Arduino] Missing "return value" (#173)

I am aware this can generate a warning (that can be turned off), but can you confirm by 'exception' you mean the code crashes or do you mean "generates a warning"?

On Jul 15, 2021, at 8:49 PM, J-Lacerte @.<mailto:@.>> wrote:

In the "MySQL_Encrypt_Sha1.cpp" file of the "MySQL_Connector_Arduino" library, there are two functions:

size_t Encrypt_SHA1 :: write (uint8_t data) {...} size_t Encrypt_SHA1 :: write (uint8_t * data, int length) {...} according to their definition, they should make a "return" of a value of type "size_t" but neither one has a "return" which causes in my Windows 10 environment an exception. To be able to use this library, I added to these functions a "return -1;" Is it possible to correct this problem. Thank you

You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/173, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYAPTD642B26L52HOU3TX56ZJANCNFSM5AOSWPNQ.

- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FChuckBell%2FMySQL_Connector_Arduino%2Fissues%2F173%23issuecomment-882104875&data=04%7C01%7C%7C262a5bd5aaf7400050a108d94a20df2a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637622327312131194%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=kbgA3uMQTgRwGIoczS%2F%2BCx5e%2BF8DQ3I8wo3PxBRGezg%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKZNLU6DNILQFFKEGBGGO3DTYMSJRANCNFSM5AOSWPNQ&data=04%7C01%7C%7C262a5bd5aaf7400050a108d94a20df2a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637622327312141151%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=QpO7pu7dPjWSaeyaYqC5l77dsisIxTYMwsIxwXOvHZs%3D&reserved=0.

davidepalladino commented 2 years ago

Me too! I tried to suppress -Werror=return-type on build_unflags of platformio.ini, but an exception is generated. I'm using CLion with PlatformIO.

Tommy5602 commented 2 years ago

One possible solution would be ` size_t Encrypt_SHA1::write(uint8_t data) { ++byteCount; addUncounted(data); return 1; }

size_t Encrypt_SHA1::write(uint8_t* data, int length) { for (int i=0; i<length; i++) { write(data[i]); } return length; } `