Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 68030a5

Browse files
committedMay 28, 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.
1 parent d2535e6 commit 68030a5

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed
 

‎src/http.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ static int op_parse_url(OpusParsedURL *_dst,const char *_src){
623623
op_parsed_url_init(&url);
624624
ret=op_parse_url_impl(&url,_src);
625625
if(OP_UNLIKELY(ret<0))op_parsed_url_clear(&url);
626-
else *_dst=*&url;
626+
else *_dst=url;
627627
return ret;
628628
}
629629

@@ -1068,7 +1068,7 @@ static void op_http_conn_read_rate_update(OpusHTTPConn *_conn){
10681068
read_rate=_conn->read_rate;
10691069
read_delta_ms=OP_MAX(read_delta_ms,1);
10701070
read_rate+=read_delta_bytes*1000/read_delta_ms-read_rate+4>>3;
1071-
*&_conn->read_time=*&read_time;
1071+
_conn->read_time=read_time;
10721072
_conn->read_bytes=0;
10731073
_conn->read_rate=read_rate;
10741074
}
@@ -2087,7 +2087,7 @@ static int op_http_connect_impl(OpusHTTPStream *_stream,OpusHTTPConn *_conn,
20872087
_conn->next=_stream->lru_head;
20882088
_stream->lru_head=_conn;
20892089
op_time_get(_start_time);
2090-
*&_conn->read_time=*_start_time;
2090+
_conn->read_time=*_start_time;
20912091
_conn->read_bytes=0;
20922092
_conn->read_rate=0;
20932093
/*Try to start a connection to each protocol.
@@ -2201,7 +2201,7 @@ static int op_http_connect(OpusHTTPStream *_stream,OpusHTTPConn *_conn,
22012201
new_addrs=op_resolve(_stream->connect_host,_stream->connect_port);
22022202
if(OP_LIKELY(new_addrs!=NULL)){
22032203
_addrs=new_addrs;
2204-
*&_stream->resolve_time=*&resolve_time;
2204+
_stream->resolve_time=resolve_time;
22052205
}
22062206
else if(OP_LIKELY(_addrs==NULL))return OP_FALSE;
22072207
}
@@ -2719,7 +2719,7 @@ static int op_http_stream_open(OpusHTTPStream *_stream,const char *_url,
27192719
/*Always try to skip re-resolve for proxy connections.*/
27202720
else addrs=&_stream->addr_info;
27212721
op_parsed_url_clear(&_stream->url);
2722-
*&_stream->url=*&next_url;
2722+
_stream->url=next_url;
27232723
/*TODO: On servers/proxies that support pipelining, we might be able to
27242724
re-use this connection.*/
27252725
op_http_conn_close(_stream,_stream->conns+0,&_stream->lru_head,1);
@@ -3197,7 +3197,7 @@ static int op_http_stream_seek(void *_stream,opus_int64 _offset,int _whence){
31973197
/*Mark when we deactivated the active connection.*/
31983198
if(ci>=0){
31993199
op_http_conn_read_rate_update(stream->conns+ci);
3200-
*&seek_time=*&stream->conns[ci].read_time;
3200+
seek_time=stream->conns[ci].read_time;
32013201
}
32023202
else op_time_get(&seek_time);
32033203
/*If we seeked past the end of the stream, just disable the active
@@ -3423,7 +3423,7 @@ static void *op_url_stream_create_impl(OpusFileCallbacks *_cb,const char *_url,
34233423
_ogg_free(stream);
34243424
return NULL;
34253425
}
3426-
*_cb=*&OP_HTTP_CALLBACKS;
3426+
*_cb=OP_HTTP_CALLBACKS;
34273427
return stream;
34283428
}
34293429
#else
@@ -3516,7 +3516,7 @@ void *op_url_stream_vcreate(OpusFileCallbacks *_cb,
35163516
OpusServerInfo *pinfo;
35173517
void *ret;
35183518
ret=op_url_stream_vcreate_impl(_cb,_url,&info,&pinfo,_ap);
3519-
if(pinfo!=NULL)*pinfo=*&info;
3519+
if(pinfo!=NULL)*pinfo=info;
35203520
return ret;
35213521
}
35223522

@@ -3549,7 +3549,7 @@ OggOpusFile *op_vopen_url(const char *_url,int *_error,va_list _ap){
35493549
if(pinfo!=NULL)opus_server_info_clear(&info);
35503550
(*cb.close)(source);
35513551
}
3552-
else if(pinfo!=NULL)*pinfo=*&info;
3552+
else if(pinfo!=NULL)*pinfo=info;
35533553
return of;
35543554
}
35553555

@@ -3579,7 +3579,7 @@ OggOpusFile *op_vtest_url(const char *_url,int *_error,va_list _ap){
35793579
if(pinfo!=NULL)opus_server_info_clear(&info);
35803580
(*cb.close)(source);
35813581
}
3582-
else if(pinfo!=NULL)*pinfo=*&info;
3582+
else if(pinfo!=NULL)*pinfo=info;
35833583
return of;
35843584
}
35853585

‎src/opusfile.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static int op_get_prev_page_serial(OggOpusFile *_of,OpusSeekRecord *_sr,
360360
/*If this page is from the stream we're looking for, remember it.*/
361361
if(serialno==_serialno){
362362
preferred_found=1;
363-
*&preferred_sr=*_sr;
363+
preferred_sr=*_sr;
364364
}
365365
if(!op_lookup_serialno(serialno,_serialnos,_nserialnos)){
366366
/*We fell off the end of the link, which means we seeked back too far
@@ -381,7 +381,7 @@ static int op_get_prev_page_serial(OggOpusFile *_of,OpusSeekRecord *_sr,
381381
end=OP_MIN(begin+OP_PAGE_SIZE_MAX-1,original_end);
382382
}
383383
while(_offset<0);
384-
if(preferred_found)*_sr=*&preferred_sr;
384+
if(preferred_found)*_sr=preferred_sr;
385385
return 0;
386386
}
387387

@@ -1445,8 +1445,8 @@ static int op_open_seekable2(OggOpusFile *_of){
14451445
/*This is a bit too large to put on the stack unconditionally.*/
14461446
op_start=(ogg_packet *)_ogg_malloc(sizeof(*op_start)*start_op_count);
14471447
if(op_start==NULL)return OP_EFAULT;
1448-
*&oy_start=_of->oy;
1449-
*&os_start=_of->os;
1448+
oy_start=_of->oy;
1449+
os_start=_of->os;
14501450
prev_page_offset=_of->prev_page_offset;
14511451
start_offset=_of->offset;
14521452
memcpy(op_start,_of->op,sizeof(*op_start)*start_op_count);
@@ -1457,8 +1457,8 @@ static int op_open_seekable2(OggOpusFile *_of){
14571457
/*Restore the old stream state.*/
14581458
ogg_stream_clear(&_of->os);
14591459
ogg_sync_clear(&_of->oy);
1460-
*&_of->oy=*&oy_start;
1461-
*&_of->os=*&os_start;
1460+
_of->oy=oy_start;
1461+
_of->os=os_start;
14621462
_of->offset=start_offset;
14631463
_of->op_count=start_op_count;
14641464
memcpy(_of->op,op_start,sizeof(*_of->op)*start_op_count);
@@ -1521,7 +1521,7 @@ static int op_open1(OggOpusFile *_of,
15211521
if(OP_UNLIKELY(_initial_bytes>(size_t)LONG_MAX))return OP_EFAULT;
15221522
_of->end=-1;
15231523
_of->stream=_stream;
1524-
*&_of->callbacks=*_cb;
1524+
_of->callbacks=*_cb;
15251525
/*At a minimum, we need to be able to read data.*/
15261526
if(OP_UNLIKELY(_of->callbacks.read==NULL))return OP_EREAD;
15271527
/*Initialize the framing state.*/
@@ -1887,7 +1887,7 @@ static int op_fetch_and_process_page(OggOpusFile *_of,
18871887
OP_ASSERT(_of->ready_state>=OP_OPENED);
18881888
/*If we were given a page to use, use it.*/
18891889
if(_og!=NULL){
1890-
*&og=*_og;
1890+
og=*_og;
18911891
_og=NULL;
18921892
}
18931893
/*Keep reading until we get a page with the correct serialno.*/

0 commit comments

Comments
 (0)
Please sign in to comment.