]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: use C++11 initializers for some DiskThreads classes
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 26 Oct 2016 18:17:55 +0000 (07:17 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 26 Oct 2016 18:17:55 +0000 (07:17 +1300)
Fixes AIOCounts wrong values due to uninitialized struct.

Fixes wrong pointer initialization in squidaio_ctrl_t.

src/DiskIO/DiskThreads/DiskThreads.h
src/DiskIO/DiskThreads/async_io.cc

index 9da2752da36ae4fa92c90f590b9a47254cc48af6..1a05e9478b76281414a44148597c7b73e130ca6e 100644 (file)
@@ -56,29 +56,29 @@ typedef enum _squidaio_request_type squidaio_request_type;
 
 typedef void AIOCB(int fd, void *cbdata, const char *buf, int aio_return, int aio_errno);
 
-class squidaio_result_t {
+class squidaio_result_t
+{
 public:
-    squidaio_result_t() : aio_return(0), aio_errno(0), result_type(_AIO_OP_NONE), _data(nullptr), data(nullptr) {}
-    int aio_return;
-    int aio_errno;
-    enum _squidaio_request_type result_type;
-    void *_data;        /* Internal housekeeping */
-    void *data;         /* Available to the caller */
+    int aio_return = 0;
+    int aio_errno = 0;
+    enum _squidaio_request_type result_type = _AIO_OP_NONE;
+    void *_data = nullptr;        /* Internal housekeeping */
+    void *data = nullptr;         /* Available to the caller */
 };
 
-class squidaio_ctrl_t {
+class squidaio_ctrl_t
+{
     MEMPROXY_CLASS(squidaio_ctrl_t);
 public:
-    squidaio_ctrl_t() : next(nullptr), fd(0), operation(0), done_handler(nullptr), done_handler_data(nullptr), len(0), bufp(0), free_func(nullptr) {}
-    struct squidaio_ctrl_t *next;
-    int fd;
-    int operation;
-    AIOCB *done_handler;
-    void *done_handler_data;
+    squidaio_ctrl_t *next = nullptr;
+    int fd = 0;
+    int operation = 0;
+    AIOCB *done_handler = nullptr;
+    void *done_handler_data = nullptr;
     squidaio_result_t result;
-    int len;
-    char *bufp;
-    FREE *free_func;
+    int len = 0;
+    char *bufp = nullptr;
+    FREE *free_func = nullptr;
     dlink_node node;
 };
 
@@ -117,21 +117,23 @@ int aioQueueSize(void);
 
 class DiskThreadsIOStrategy;
 
-struct AIOCounts {
-    uint64_t open_start;
-    uint64_t open_finish;
-    uint64_t close_start;
-    uint64_t close_finish;
-    uint64_t cancel;
-    uint64_t write_start;
-    uint64_t write_finish;
-    uint64_t read_start;
-    uint64_t read_finish;
-    uint64_t stat_start;
-    uint64_t stat_finish;
-    uint64_t unlink_start;
-    uint64_t unlink_finish;
-    uint64_t check_callback;
+class AIOCounts
+{
+public:
+    uint64_t open_start = 0;
+    uint64_t open_finish = 0;
+    uint64_t close_start = 0;
+    uint64_t close_finish = 0;
+    uint64_t cancel = 0;
+    uint64_t write_start = 0;
+    uint64_t write_finish = 0;
+    uint64_t read_start = 0;
+    uint64_t read_finish = 0;
+    uint64_t stat_start = 0;
+    uint64_t stat_finish = 0;
+    uint64_t unlink_start = 0;
+    uint64_t unlink_finish = 0;
+    uint64_t check_callback = 0;
 };
 
 extern AIOCounts squidaio_counts;
index 5bfd1c960bae2d95b6316cf8c84b5efd02a9c61f..34f21274764ff4b5ffe1a24d62b6e0bd1dbfd881 100644 (file)
 #include "Generic.h"
 #include "Store.h"
 
-/*
- * squidaio_ctrl_t uses explicit alloc()/freeOne() allocators
- * XXX: convert to MEMPROXY_CLASS() API
- */
-#include "mem/Pool.h"
-
 AIOCounts squidaio_counts;
 
 typedef struct squidaio_unlinkq_t {