shithub: opusfile

Download patch

ref: 68030a507962284d583416ee37f9a8e580bf369f
parent: d2535e62809079c81f9e5139c0daebe43af97be4
author: Tamir Duberstein <tamird@gmail.com>
date: Wed May 28 06:20:58 EDT 2025

Remove useless pointer pattern

This simply removes all instances of the bizarre pattern `*&` which
takes a pointer and immediately dereferences it. This pattern seems to
be adversarial to HWASAN.

Fixes #57.

--- a/src/http.c
+++ b/src/http.c
@@ -623,7 +623,7 @@
   op_parsed_url_init(&url);
   ret=op_parse_url_impl(&url,_src);
   if(OP_UNLIKELY(ret<0))op_parsed_url_clear(&url);
-  else *_dst=*&url;
+  else *_dst=url;
   return ret;
 }
 
@@ -1068,7 +1068,7 @@
   read_rate=_conn->read_rate;
   read_delta_ms=OP_MAX(read_delta_ms,1);
   read_rate+=read_delta_bytes*1000/read_delta_ms-read_rate+4>>3;
-  *&_conn->read_time=*&read_time;
+  _conn->read_time=read_time;
   _conn->read_bytes=0;
   _conn->read_rate=read_rate;
 }
@@ -2087,7 +2087,7 @@
   _conn->next=_stream->lru_head;
   _stream->lru_head=_conn;
   op_time_get(_start_time);
-  *&_conn->read_time=*_start_time;
+  _conn->read_time=*_start_time;
   _conn->read_bytes=0;
   _conn->read_rate=0;
   /*Try to start a connection to each protocol.
@@ -2201,7 +2201,7 @@
     new_addrs=op_resolve(_stream->connect_host,_stream->connect_port);
     if(OP_LIKELY(new_addrs!=NULL)){
       _addrs=new_addrs;
-      *&_stream->resolve_time=*&resolve_time;
+      _stream->resolve_time=resolve_time;
     }
     else if(OP_LIKELY(_addrs==NULL))return OP_FALSE;
   }
@@ -2719,7 +2719,7 @@
     /*Always try to skip re-resolve for proxy connections.*/
     else addrs=&_stream->addr_info;
     op_parsed_url_clear(&_stream->url);
-    *&_stream->url=*&next_url;
+    _stream->url=next_url;
     /*TODO: On servers/proxies that support pipelining, we might be able to
        re-use this connection.*/
     op_http_conn_close(_stream,_stream->conns+0,&_stream->lru_head,1);
@@ -3197,7 +3197,7 @@
   /*Mark when we deactivated the active connection.*/
   if(ci>=0){
     op_http_conn_read_rate_update(stream->conns+ci);
-    *&seek_time=*&stream->conns[ci].read_time;
+    seek_time=stream->conns[ci].read_time;
   }
   else op_time_get(&seek_time);
   /*If we seeked past the end of the stream, just disable the active
@@ -3423,7 +3423,7 @@
       _ogg_free(stream);
       return NULL;
     }
-    *_cb=*&OP_HTTP_CALLBACKS;
+    *_cb=OP_HTTP_CALLBACKS;
     return stream;
   }
 #else
@@ -3516,7 +3516,7 @@
   OpusServerInfo *pinfo;
   void *ret;
   ret=op_url_stream_vcreate_impl(_cb,_url,&info,&pinfo,_ap);
-  if(pinfo!=NULL)*pinfo=*&info;
+  if(pinfo!=NULL)*pinfo=info;
   return ret;
 }
 
@@ -3549,7 +3549,7 @@
     if(pinfo!=NULL)opus_server_info_clear(&info);
     (*cb.close)(source);
   }
-  else if(pinfo!=NULL)*pinfo=*&info;
+  else if(pinfo!=NULL)*pinfo=info;
   return of;
 }
 
@@ -3579,7 +3579,7 @@
     if(pinfo!=NULL)opus_server_info_clear(&info);
     (*cb.close)(source);
   }
-  else if(pinfo!=NULL)*pinfo=*&info;
+  else if(pinfo!=NULL)*pinfo=info;
   return of;
 }
 
--- a/src/opusfile.c
+++ b/src/opusfile.c
@@ -360,7 +360,7 @@
       /*If this page is from the stream we're looking for, remember it.*/
       if(serialno==_serialno){
         preferred_found=1;
-        *&preferred_sr=*_sr;
+        preferred_sr=*_sr;
       }
       if(!op_lookup_serialno(serialno,_serialnos,_nserialnos)){
         /*We fell off the end of the link, which means we seeked back too far
@@ -381,7 +381,7 @@
     end=OP_MIN(begin+OP_PAGE_SIZE_MAX-1,original_end);
   }
   while(_offset<0);
-  if(preferred_found)*_sr=*&preferred_sr;
+  if(preferred_found)*_sr=preferred_sr;
   return 0;
 }
 
@@ -1445,8 +1445,8 @@
   /*This is a bit too large to put on the stack unconditionally.*/
   op_start=(ogg_packet *)_ogg_malloc(sizeof(*op_start)*start_op_count);
   if(op_start==NULL)return OP_EFAULT;
-  *&oy_start=_of->oy;
-  *&os_start=_of->os;
+  oy_start=_of->oy;
+  os_start=_of->os;
   prev_page_offset=_of->prev_page_offset;
   start_offset=_of->offset;
   memcpy(op_start,_of->op,sizeof(*op_start)*start_op_count);
@@ -1457,8 +1457,8 @@
   /*Restore the old stream state.*/
   ogg_stream_clear(&_of->os);
   ogg_sync_clear(&_of->oy);
-  *&_of->oy=*&oy_start;
-  *&_of->os=*&os_start;
+  _of->oy=oy_start;
+  _of->os=os_start;
   _of->offset=start_offset;
   _of->op_count=start_op_count;
   memcpy(_of->op,op_start,sizeof(*_of->op)*start_op_count);
@@ -1521,7 +1521,7 @@
   if(OP_UNLIKELY(_initial_bytes>(size_t)LONG_MAX))return OP_EFAULT;
   _of->end=-1;
   _of->stream=_stream;
-  *&_of->callbacks=*_cb;
+  _of->callbacks=*_cb;
   /*At a minimum, we need to be able to read data.*/
   if(OP_UNLIKELY(_of->callbacks.read==NULL))return OP_EREAD;
   /*Initialize the framing state.*/
@@ -1887,7 +1887,7 @@
     OP_ASSERT(_of->ready_state>=OP_OPENED);
     /*If we were given a page to use, use it.*/
     if(_og!=NULL){
-      *&og=*_og;
+      og=*_og;
       _og=NULL;
     }
     /*Keep reading until we get a page with the correct serialno.*/
--