[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 4b97001 2/2: Memcpy's first argument NULL warn
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 4b97001 2/2: Memcpy's first argument NULL warning corrected |
Date: |
Mon, 29 May 2017 12:42:42 -0400 (EDT) |
branch: master
commit 4b97001f4b48c8368078c71a316ca82474ec1337
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Memcpy's first argument NULL warning corrected
After updating to GCC 7.1.1, a warning came up about the possibility of
`memcpy's first argument being NULL. To correct it, an `if(o)' was put
before memcpy. It won't affect the efficiency, because it won't be NULL
when we use it and the compiler will optimize it.
---
lib/gnuastro/tile.h | 6 +++---
lib/tile.c | 6 ++++--
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/gnuastro/tile.h b/lib/gnuastro/tile.h
index 0ae7af4..0d17484 100644
--- a/lib/gnuastro/tile.h
+++ b/lib/gnuastro/tile.h
@@ -240,9 +240,9 @@ gal_tile_full_free_contents(struct
gal_tile_two_layer_params *tl);
/* tile, we need to increment to the next contiguous patch */ \
/* of memory to continue parsing this tile. */ \
tpo_increment += ( IN==tpo_iblock ? tpo_iblock->size \
- : gal_tile_block_increment(tpo_iblock, IN->dsize, \
- tpo_num_increment++, \
- NULL) ); \
+ : gal_tile_block_increment(tpo_iblock, IN->dsize, \
+ tpo_num_increment++, \
+ NULL) ); \
} \
\
/* This is done in case the caller doesn't need `o' to avoid */ \
diff --git a/lib/tile.c b/lib/tile.c
index d1c934a..6ecbbad 100644
--- a/lib/tile.c
+++ b/lib/tile.c
@@ -463,10 +463,12 @@ gal_tile_block_write_const_value(gal_data_t *tilevalues,
gal_data_t *tilesll,
tile_ind=0;
for(tile=tilesll; tile!=NULL; tile=tile->next)
{
- /* Set the pointer to use as input. */
+ /* Set the pointer to use as input. The `if(o)' statement is set
+ because GCC 7.1.1 complained about the possiblity of the first
+ argument of `memcpy' being NULL. */
in=gal_data_ptr_increment(tilevalues->array, tile_ind++, type);;
GAL_TILE_PARSE_OPERATE( tile, tofill, 1, 0, {
- memcpy(o, in, gal_type_sizeof(type));
+ if(o) memcpy(o, in, gal_type_sizeof(type));
} );
}