Skip to content

Commit

Permalink
Fix some low-hanging warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
markusdregi committed Jun 20, 2017
1 parent a77c6f8 commit 380df93
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/util/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ void buffer_memshift(buffer_type * buffer , size_t offset, ssize_t shift) {
{
size_t move_size;
if (shift < 0)
if (abs(shift) > offset)
offset = abs(shift); /* We are 'trying' to left shift beyond the start of the buffer. */
if (labs(shift) > offset)
offset = labs(shift); /* We are 'trying' to left shift beyond the start of the buffer. */

move_size = buffer->content_size - offset;
memmove( &buffer->data[offset + shift] , &buffer->data[offset] , move_size );
Expand Down Expand Up @@ -763,7 +763,7 @@ buffer_type * buffer_fread_alloc(const char * filename) {
*/

size_t buffer_stream_fwrite_n( const buffer_type * buffer , size_t offset , ssize_t write_size , FILE * stream ) {
if (offset < 0 || offset > buffer->content_size)
if (offset > buffer->content_size)
util_abort("%s: invalid offset:%ld - valid range: [0,%ld) \n",__func__ , offset , offset);
{
ssize_t len;
Expand All @@ -773,7 +773,7 @@ size_t buffer_stream_fwrite_n( const buffer_type * buffer , size_t offset , ssiz
else if (write_size == 0) /* Write everything from the offset */
len = buffer->content_size - offset;
else /* @write_size < 0 - write everything excluding the last abs(write_size) bytes. */
len = buffer->content_size - offset - abs( write_size );
len = buffer->content_size - offset - labs( write_size );

if (len < 0)
util_abort("%s: invalid length spesifier - tried to write %ld bytes \n",__func__ , len);
Expand Down
4 changes: 2 additions & 2 deletions lib/util/test_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void test_error_exit( const char * fmt , ...) {
va_start(ap , fmt);
s = util_alloc_sprintf_va(fmt , ap);
va_end(ap);
fprintf(stderr , s );
fprintf(stderr, "%s", s);
exit(1);
}

Expand All @@ -50,7 +50,7 @@ void test_exit__(const char * file , int line , const char * fmt , ...) {
va_start(ap , fmt);
s = util_alloc_sprintf_va(fmt , ap);
va_end(ap);
fprintf(stderr , s );
fprintf(stderr, "%s", s);
exit(1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/util/util_abort_gnu.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ static bool util_addr2line_lookup__(const void * bt_addr , char ** func_name , c
*line_nr = 0;
{
bool address_found = false;
Dl_info dl_info;
#if defined(__APPLE__)
return false;
return address_found;
#else
Dl_info dl_info;
if (dladdr(bt_addr , &dl_info)) {
const char * executable = dl_info.dli_fname;
*func_name = util_alloc_string_copy( dl_info.dli_sname );
Expand Down

0 comments on commit 380df93

Please sign in to comment.