You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2019/04/23 14:14:31 UTC

[trafficserver] branch master updated: cppcheck: Use initialization list instead of assigning in constructor body

This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 3c3d994  cppcheck: Use initialization list instead of assigning in constructor body
3c3d994 is described below

commit 3c3d9941ad65f2861ada076a76b40e9e6835d7bd
Author: Masaori Koshiba <ma...@gmail.com>
AuthorDate: Tue Apr 23 16:04:38 2019 +0800

    cppcheck: Use initialization list instead of assigning in constructor body
    
    > [Http2ClientSession.h:77]: (performance) Variable 'hdr' is assigned in constructor body. Consider performing initialization in initialization list.
    > [Http2ClientSession.h:83]: (performance) Variable 'hdr' is assigned in constructor body. Consider performing initialization in initialization list.
---
 proxy/http2/Http2ClientSession.h | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/proxy/http2/Http2ClientSession.h b/proxy/http2/Http2ClientSession.h
index 23b0f53..b6d1fae 100644
--- a/proxy/http2/Http2ClientSession.h
+++ b/proxy/http2/Http2ClientSession.h
@@ -72,17 +72,8 @@ struct Http2UpgradeContext {
 class Http2Frame
 {
 public:
-  Http2Frame(const Http2FrameHeader &h, IOBufferReader *r)
-  {
-    this->hdr      = h;
-    this->ioreader = r;
-  }
-
-  Http2Frame(Http2FrameType type, Http2StreamId streamid, uint8_t flags)
-  {
-    this->hdr      = {0, (uint8_t)type, flags, streamid};
-    this->ioreader = nullptr;
-  }
+  Http2Frame(const Http2FrameHeader &h, IOBufferReader *r) : hdr(h), ioreader(r) {}
+  Http2Frame(Http2FrameType type, Http2StreamId streamid, uint8_t flags) : hdr({0, (uint8_t)type, flags, streamid}) {}
 
   IOBufferReader *
   reader() const
@@ -155,7 +146,7 @@ public:
 private:
   Http2FrameHeader hdr;       // frame header
   Ptr<IOBufferBlock> ioblock; // frame payload
-  IOBufferReader *ioreader;
+  IOBufferReader *ioreader = nullptr;
 };
 
 class Http2ClientSession : public ProxyClientSession