Explorar o código

rm cppcheck warnings

ithewei %!s(int64=2) %!d(string=hai) anos
pai
achega
e9763f0d18

+ 1 - 0
cpputil/hfile.h

@@ -9,6 +9,7 @@
 class HFile {
 public:
     HFile() {
+        filepath[0] = '\0';
         fp = NULL;
     }
 

+ 3 - 3
event/hloop.c

@@ -914,9 +914,9 @@ hio_t* hsendto (hloop_t* loop, int sockfd, const void* buf, size_t len, hwrite_c
 
 //-----------------top-level apis---------------------------------------------
 hio_t* hio_create_socket(hloop_t* loop, const char* host, int port, hio_type_e type, hio_side_e side) {
-    int sock_type = type & HIO_TYPE_SOCK_STREAM ? SOCK_STREAM :
-                    type & HIO_TYPE_SOCK_DGRAM  ? SOCK_DGRAM :
-                    type & HIO_TYPE_SOCK_RAW    ? SOCK_RAW : -1;
+    int sock_type = (type & HIO_TYPE_SOCK_STREAM) ? SOCK_STREAM :
+                    (type & HIO_TYPE_SOCK_DGRAM)  ? SOCK_DGRAM :
+                    (type & HIO_TYPE_SOCK_RAW)    ? SOCK_RAW : -1;
     if (sock_type == -1) return NULL;
     sockaddr_u addr;
     memset(&addr, 0, sizeof(addr));

+ 1 - 0
evpp/TcpClient.h

@@ -17,6 +17,7 @@ public:
 
     TcpClientEventLoopTmpl(EventLoopPtr loop = NULL) {
         loop_ = loop ? loop : std::make_shared<EventLoop>();
+        remote_port = 0;
         connect_timeout = HIO_DEFAULT_CONNECT_TIMEOUT;
         tls = false;
         tls_setting = NULL;

+ 1 - 0
evpp/TcpServer.h

@@ -17,6 +17,7 @@ public:
 
     TcpServerEventLoopTmpl(EventLoopPtr loop = NULL) {
         acceptor_loop = loop ? loop : std::make_shared<EventLoop>();
+        port = 0;
         listenfd = -1;
         tls = false;
         tls_setting = NULL;

+ 1 - 0
evpp/UdpClient.h

@@ -15,6 +15,7 @@ public:
 
     UdpClientEventLoopTmpl(EventLoopPtr loop = NULL) {
         loop_ = loop ? loop : std::make_shared<EventLoop>();
+        remote_port = 0;
 #if WITH_KCP
         enable_kcp = false;
 #endif

+ 1 - 0
evpp/UdpServer.h

@@ -15,6 +15,7 @@ public:
 
     UdpServerEventLoopTmpl(EventLoopPtr loop = NULL) {
         loop_ = loop ? loop : std::make_shared<EventLoop>();
+        port = 0;
 #if WITH_KCP
         enable_kcp = false;
 #endif

+ 1 - 0
http/WebSocketChannel.h

@@ -16,6 +16,7 @@ public:
     WebSocketChannel(hio_t* io, ws_session_type type = WS_CLIENT)
         : SocketChannel(io)
         , type(type)
+        , opcode(WS_OPCODE_CLOSE)
     {}
     ~WebSocketChannel() {}
 

+ 1 - 0
http/WebSocketParser.cpp

@@ -60,6 +60,7 @@ WebSocketParser::WebSocketParser() {
     websocket_parser_init(parser);
     parser->data = this;
     state = WS_FRAME_BEGIN;
+    opcode = WS_OP_CLOSE;
 }
 
 WebSocketParser::~WebSocketParser() {

+ 3 - 1
http/client/http_client.cpp

@@ -51,6 +51,8 @@ struct http_client_s {
         port = DEFAULT_HTTP_PORT;
         https = 0;
         timeout = DEFAULT_HTTP_TIMEOUT;
+        http_proxy_port = DEFAULT_HTTP_PORT;
+        https_proxy_port = DEFAULT_HTTP_PORT;
 #ifdef WITH_CURL
         curl = NULL;
 #endif
@@ -256,7 +258,7 @@ static size_t s_header_cb(char* buf, size_t size, size_t cnt, void* userdata) {
         if (strncmp(buf, "HTTP/", 5) == 0) {
             // status line
             //hlogd("%s", buf);
-            int http_major,http_minor,status_code;
+            int http_major = 1, http_minor = 1, status_code = 200;
             if (buf[5] == '1') {
                 // HTTP/1.1 200 OK\r\n
                 sscanf(buf, "HTTP/%d.%d %d", &http_major, &http_minor, &status_code);

+ 2 - 0
http/multipart_parser.c

@@ -18,6 +18,8 @@ static void multipart_log(const char * format, ...)
     fprintf(stderr, "[HTTP_MULTIPART_PARSER] %s:%d: ", __FILE__, __LINE__);
     vfprintf(stderr, format, args);
     fprintf(stderr, "\n");
+
+    va_end(args);
 #endif
 }
 

+ 1 - 0
http/server/HttpResponseWriter.h

@@ -21,6 +21,7 @@ public:
         : SocketChannel(io)
         , response(resp)
         , state(SEND_BEGIN)
+        , end(SEND_BEGIN)
     {}
     ~HttpResponseWriter() {}
 

+ 9 - 9
unittest/listdir_test.cpp

@@ -12,15 +12,15 @@ int main(int argc, char* argv[]) {
     for (auto& item : dirs) {
         printf("%c%c%c%c%c%c%c%c%c%c\t",
             item.type,
-            item.mode & 0400 ? 'r' : '-',
-            item.mode & 0200 ? 'w' : '-',
-            item.mode & 0100 ? 'x' : '-',
-            item.mode & 0040 ? 'r' : '-',
-            item.mode & 0020 ? 'w' : '-',
-            item.mode & 0010 ? 'x' : '-',
-            item.mode & 0004 ? 'r' : '-',
-            item.mode & 0002 ? 'w' : '-',
-            item.mode & 0001 ? 'x' : '-');
+            (item.mode & 0400) ? 'r' : '-',
+            (item.mode & 0200) ? 'w' : '-',
+            (item.mode & 0100) ? 'x' : '-',
+            (item.mode & 0040) ? 'r' : '-',
+            (item.mode & 0020) ? 'w' : '-',
+            (item.mode & 0010) ? 'x' : '-',
+            (item.mode & 0004) ? 'r' : '-',
+            (item.mode & 0002) ? 'w' : '-',
+            (item.mode & 0001) ? 'x' : '-');
         float hsize;
         if (item.size < 1024) {
             printf("%lu\t", item.size);