11use core:: ffi:: { c_char, c_int, c_long, c_void, CStr } ;
2+ use core:: ptr;
23use std:: io;
34
45// nb. cannot use any BIO types from openssl_sys: it doesn't
@@ -57,15 +58,15 @@ impl Bio {
5758 //
5859 // If neither the rbio or wbio have changed from their
5960 // previous values then nothing is done.
60- if rbio == self . read && wbio == self . write {
61+ if ptr :: eq ( rbio, self . read ) && ptr :: eq ( wbio, self . write ) {
6162 return ;
6263 }
6364
6465 // If the rbio and wbio parameters are different and both are
6566 // different to their previously set values then one reference
6667 // is consumed for the rbio and one reference is consumed for
6768 // the wbio.
68- if rbio != wbio && rbio != self . read && wbio != self . write {
69+ if !ptr :: eq ( rbio, wbio) && !ptr :: eq ( rbio, self . read ) && !ptr :: eq ( wbio, self . write ) {
6970 self . set_read ( rbio) ;
7071 self . set_write ( wbio) ;
7172 return ;
@@ -74,7 +75,7 @@ impl Bio {
7475 // If the rbio and wbio parameters are the same and the rbio
7576 // is not the same as the previously set value then one reference
7677 // is consumed for the rbio.
77- if rbio == wbio && rbio != self . read {
78+ if ptr :: eq ( rbio, wbio) && !ptr :: eq ( rbio, self . read ) {
7879 unsafe {
7980 BIO_up_ref ( rbio) ;
8081 }
@@ -86,7 +87,7 @@ impl Bio {
8687 // If the rbio and wbio parameters are the same and the rbio
8788 // is the same as the previously set value, then no additional
8889 // references are consumed.
89- if rbio == wbio && rbio == self . read {
90+ if ptr :: eq ( rbio, wbio) && ptr :: eq ( rbio, self . read ) {
9091 // (er, what about self.write though?)
9192 return ;
9293 }
@@ -95,7 +96,7 @@ impl Bio {
9596 // is the same as the previously set value then one reference
9697 // is consumed for the wbio and no references are consumed for
9798 // the rbio.
98- if rbio != wbio && rbio == self . read {
99+ if !ptr :: eq ( rbio, wbio) && ptr :: eq ( rbio, self . read ) {
99100 self . set_write ( wbio) ;
100101 return ;
101102 }
@@ -105,7 +106,10 @@ impl Bio {
105106 // wbio values were the same as each other then one reference
106107 // is consumed for the rbio and no references are consumed for
107108 // the wbio.
108- if rbio != wbio && wbio == self . write && self . read == self . write {
109+ if !ptr:: eq ( rbio, wbio)
110+ && ptr:: eq ( wbio, self . write )
111+ && ptr:: eq ( self . read , self . write )
112+ {
109113 self . set_read ( rbio) ;
110114 return ;
111115 }
@@ -114,7 +118,10 @@ impl Bio {
114118 // is the same as the previously set value and the old rbio and
115119 // wbio values were different to each other, then one reference
116120 // is consumed for the rbio and one reference is consumed for the wbio.
117- if rbio != wbio && wbio == self . write && self . read != self . write {
121+ if !ptr:: eq ( rbio, wbio)
122+ && ptr:: eq ( wbio, self . write )
123+ && !ptr:: eq ( self . read , self . write )
124+ {
118125 self . set_read ( rbio) ;
119126 self . set_write ( wbio) ;
120127 }
@@ -136,7 +143,7 @@ impl Bio {
136143 ///
137144 /// `wbio` must be non-NULL.
138145 fn set_write ( & mut self , wbio : * mut BIO ) {
139- if wbio != self . write {
146+ if !ptr :: eq ( wbio, self . write ) {
140147 unsafe { BIO_free_all ( self . write ) } ;
141148 self . write = wbio;
142149 } else {
@@ -151,7 +158,7 @@ impl Bio {
151158 ///
152159 /// `rbio` must be non-NULL.
153160 fn set_read ( & mut self , rbio : * mut BIO ) {
154- if rbio != self . read {
161+ if !ptr :: eq ( rbio, self . read ) {
155162 unsafe { BIO_free_all ( self . read ) } ;
156163 self . read = rbio;
157164 } else {
0 commit comments