Просмотр исходного кода

fix: libmqtt的几个方法加上static,避免与第三方库冲突

Wendal Chen 5 лет назад
Родитель
Сommit
2895e14a23
2 измененных файлов с 4 добавлено и 4 удалено
  1. 1 1
      luat/modules/luat_lib_i2c.c
  2. 3 3
      luat/modules/luat_lib_mqttcore.c

+ 1 - 1
luat/modules/luat_lib_i2c.c

@@ -65,7 +65,7 @@ i2c.send(1, 0x5C, string.char(0x0F, 0x2F))
 static int l_i2c_send(lua_State *L) {
     int id = luaL_checkinteger(L, 1);
     int addr = luaL_checkinteger(L, 2);
-    size_t len;
+    size_t len = 0;
     int result = 0;
     if (lua_isstring(L, 3)) {
         const char* buff = luaL_checklstring(L, 3, &len);

+ 3 - 3
luat/modules/luat_lib_mqttcore.c

@@ -25,7 +25,7 @@ static const char *packet_names[] =
 	"PINGREQ", "PINGRESP", "DISCONNECT", "AUTH"
 };
 
-const char** MQTTClient_packet_names = packet_names;
+static const char** MQTTClient_packet_names = packet_names;
 
 
 /**
@@ -33,7 +33,7 @@ const char** MQTTClient_packet_names = packet_names;
  * @param ptype packet code
  * @return the corresponding string, or "UNKNOWN"
  */
-const char* MQTTPacket_name(int ptype)
+static const char* MQTTPacket_name(int ptype)
 {
 	return (ptype >= 0 && ptype <= AUTH) ? packet_names[ptype] : "UNKNOWN";
 }
@@ -44,7 +44,7 @@ const char* MQTTPacket_name(int ptype)
  * @param length the length to be encoded
  * @return the number of bytes written to buffer
  */
-int MQTTPacket_encode(char* buf, size_t length)
+static int MQTTPacket_encode(char* buf, size_t length)
 {
 	int rc = 0;