Re: [PR] Fix scoped_refptr leave ptr_ uninit when move construct by nullptr (brpc)

2024-01-02 Thread via GitHub


TousakaRin merged PR #2491:
URL: https://github.com/apache/brpc/pull/2491


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



Re: [PR] Fix scoped_refptr leave ptr_ uninit when move construct by nullptr (brpc)

2024-01-02 Thread via GitHub


lengmoXXL commented on code in PR #2491:
URL: https://github.com/apache/brpc/pull/2491#discussion_r1440105137


##
src/butil/memory/ref_counted.h:
##
@@ -285,21 +285,19 @@ class scoped_refptr {
   ptr_->AddRef();
   }
 
-  scoped_refptr(scoped_refptr&& r) noexcept {
+  scoped_refptr(scoped_refptr&& r) noexcept : ptr_(r.ptr_) {
 if (r.ptr_){

Review Comment:
   done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



Re: [PR] Fix scoped_refptr leave ptr_ uninit when move construct by nullptr (brpc)

2024-01-02 Thread via GitHub


TousakaRin commented on code in PR #2491:
URL: https://github.com/apache/brpc/pull/2491#discussion_r1440092282


##
src/butil/memory/ref_counted.h:
##
@@ -285,21 +285,19 @@ class scoped_refptr {
   ptr_->AddRef();
   }
 
-  scoped_refptr(scoped_refptr&& r) noexcept {
+  scoped_refptr(scoped_refptr&& r) noexcept : ptr_(r.ptr_) {
 if (r.ptr_){

Review Comment:
   这个判断去掉,直接让 r.ptr_ = nullptr; 是否更清晰一些。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



Re: [PR] Fix scoped_refptr leave ptr_ uninit when move construct by nullptr (brpc)

2024-01-02 Thread via GitHub


lengmoXXL commented on PR #2491:
URL: https://github.com/apache/brpc/pull/2491#issuecomment-1874862827

   该问题由 pr #2284 引入


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org