5ghub / 5G-NB-IoT

13 stars 6 forks source link

Library warnings #3

Open maxgerhardt opened 2 years ago

maxgerhardt commented 2 years ago

Compiling the 5G-NB-IoT_Arduino library results in a flood of warnings.

Most notable string bugs like in #2 and missing const for char* that are not written to (causing deprecated conversion from string constant to 'char*' ), wrong signedness of for iterator variables and unused variables.

Compiling .pio\build\5g_nb_iot\lib297\5G-NB-IoT_Arduino\5GHUB_I2CInterface.cpp.o
lib\5G-NB-IoT_Arduino\5G-NB-IoT_Common.cpp: In member function 'bool _5G_NB_IoT_Common::DevLocalRate(long unsigned int&, Cmd_Status_t)':
Compiling .pio\build\5g_nb_iot\lib297\5G-NB-IoT_Arduino\5GHUB_SPIInterface.cpp.o
lib\5G-NB-IoT_Arduino\5G-NB-IoT_Common.cpp:130:66: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < sizeof(Band_list)/sizeof(Band_list[0]); i++){
                                                                  ^
Compiling .pio\build\5g_nb_iot\lib297\5G-NB-IoT_Arduino\5GHUB_TSL25911.cpp.o
Archiving .pio\build\5g_nb_iot\lib4f7\libSPI.a
Archiving .pio\build\5g_nb_iot\lib8f5\libWire.a
Compiling .pio\build\5g_nb_iot\lib297\5G-NB-IoT_Arduino\bme68x.c.o
lib\5G-NB-IoT_Arduino\5G-NB-IoT_HTTP.cpp: In member function 'bool _5G_NB_IoT_HTTP::HTTPURL(char*, Cmd_Status_t)':
lib\5G-NB-IoT_Arduino\5G-NB-IoT_HTTP.cpp:79:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
                 url = "";
                     ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp: In member function 'bool _5G_NB_IoT_SSL::SetSSLCertificate(unsigned int, char*, char*, char*, bool)':
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:92:24: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     if(ca_cert_path == "" && client_cert_path == "" && client_key_path == ""){
Indexing .pio\build\5g_nb_iot\lib4f7\libSPI.a
                        ^
Indexing .pio\build\5g_nb_iot\lib8f5\libWire.a
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:92:50: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     if(ca_cert_path == "" && client_cert_path == "" && client_key_path == ""){
                                                  ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:92:75: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     if(ca_cert_path == "" && client_cert_path == "" && client_key_path == ""){
                                                                           ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:98:30: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if(ca_cert_path != "" && client_cert_path == "" && client_key_path == ""){
                              ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:98:56: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if(ca_cert_path != "" && client_cert_path == "" && client_key_path == ""){
                                                        ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:98:81: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if(ca_cert_path != "" && client_cert_path == "" && client_key_path == ""){
                                                                                 ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:129:30: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if(ca_cert_path != "" && client_cert_path != "" && client_key_path != ""){
                              ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:129:56: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if(ca_cert_path != "" && client_cert_path != "" && client_key_path != ""){
                                                        ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:129:81: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if(ca_cert_path != "" && client_cert_path != "" && client_key_path != ""){
                                                                                 ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp: In member function 'bool _5G_NB_IoT_SSL::InitSSL(unsigned int, char*, char*, char*, char*)':
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:192:20: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     if (ca_cert == "" && client_cert == "" && client_key == ""){
                    ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:192:41: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     if (ca_cert == "" && client_cert == "" && client_key == ""){
                                         ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:192:61: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     if (ca_cert == "" && client_cert == "" && client_key == ""){
                                                             ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:193:59: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
         if (SetSSLCertificate(ssl_index, "", "", "", false)){
                                                           ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:193:59: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:193:59: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:200:26: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if (ca_cert != "" && client_cert == "" && client_key == ""){
                          ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:200:47: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if (ca_cert != "" && client_cert == "" && client_key == ""){
                                               ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:200:67: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if (ca_cert != "" && client_cert == "" && client_key == ""){
                                                                   ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:220:84: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
         while (!SetSSLCertificate(ssl_index, (char*)ssl_ca_cert_name, "", "", false)){
                                                                                    ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:220:84: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:230:26: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if (ca_cert != "" && client_cert != "" && client_key != ""){
                          ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:230:47: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if (ca_cert != "" && client_cert != "" && client_key != ""){
                                               ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:230:67: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     }else if (ca_cert != "" && client_cert != "" && client_key != ""){
                                                                   ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_MQTT.cpp: In member function 'Mqtt_Client_Result_Status_t _5G_NB_IoT_MQTT::CreateMQTTClient(unsigned int, const char*, const char*, const char*)':
lib\5G-NB-IoT_Arduino\5G-NB-IoT_MQTT.cpp:142:21: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     if (username != "" && password != ""){
                     ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_MQTT.cpp:142:39: warning: comparison with string literal results in unspecified behaviour [-Waddress]
     if (username != "" && password != ""){
                                       ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_TCPIP.cpp: In member function 'bool _5G_NB_IoT_TCPIP::InitAPN(unsigned int, char*, char*, char*, char*)':
lib\5G-NB-IoT_Arduino\5G-NB-IoT_TCPIP.cpp:91:34: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
     while(!DevSimPIN("",READ_MODE)){
                                  ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_TCPIP.cpp: In member function 'bool _5G_NB_IoT_TCPIP::DevPingFunction(unsigned int, char*)':
lib\5G-NB-IoT_Arduino\5G-NB-IoT_TCPIP.cpp:291:22: warning: NULL used in arithmetic [-Wpointer-arith]
      if (*sta_buf == NULL)
                      ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_TCPIP.cpp:309:19: warning: NULL used in arithmetic [-Wpointer-arith]
   if (*sta_buf == NULL)
                   ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_SSL.cpp:214:168: warning: 'e_str' may be used uninitialized in this function [-Wmaybe-uninitialized]
                 sprintf((char*)e_str, "\r\nSSL ERROR: Error uploading file, error code: %d ,Please check the corresponding documentation for details.\r\n", f_err_code);
                                                                                                                                                                        ^
lib\5G-NB-IoT_Arduino\5G-NB-IoT_TCPIP.cpp: In member function 'bool _5G_NB_IoT_TCPIP::InitAPN(unsigned int, char*, char*, char*, char*)':
lib\5G-NB-IoT_Arduino\5G-NB-IoT_TCPIP.cpp:100:5: warning: 'i_status' may be used uninitialized in this function [-Wmaybe-uninitialized]
     while (i_status != REGISTERED && i_status != REGISTERED_ROAMING){
     ^
lib\5G-NB-IoT_Arduino\5GHUB_TSL25911.cpp: In member function 'float _5GHUB_TSL25911::CalculateLux(uint16_t, uint16_t)':
lib\5G-NB-IoT_Arduino\5GHUB_TSL25911.cpp:143:14: warning: unused variable 'lux1' [-Wunused-variable]
   float cpl, lux1, lux2, lux;
              ^
lib\5G-NB-IoT_Arduino\5GHUB_TSL25911.cpp:143:20: warning: unused variable 'lux2' [-Wunused-variable]
   float cpl, lux1, lux2, lux;
                    ^
lib\5G-NB-IoT_Arduino\5GHUB_TSL25911.cpp:144:12: warning: unused variable 'chan0' [-Wunused-variable]
   uint32_t chan0, chan1;
            ^
lib\5G-NB-IoT_Arduino\5GHUB_TSL25911.cpp:144:19: warning: unused variable 'chan1' [-Wunused-variable]
   uint32_t chan0, chan1;