Skip to content

Commit

Permalink
C: Resolve cppcheck warnings about const pointers.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinekitty committed May 28, 2024
1 parent d2b7621 commit 20a8459
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions generate/template/astronomy.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ static stardef_t StarTable[NSTARS];

#define GetStarPointer(body) (((body) >= BODY_STAR1) && ((body) <= BODY_STAR8) ? &StarTable[(body) - BODY_STAR1] : NULL)

static stardef_t *UserDefinedStar(astro_body_t body)
static const stardef_t *UserDefinedStar(astro_body_t body)
{
stardef_t *star = GetStarPointer(body);
const stardef_t *star = GetStarPointer(body);
if (star != NULL && star->dist > 0.0)
return star;
return NULL;
Expand Down Expand Up @@ -3040,7 +3040,7 @@ static body_state_t *GravSimBodyStatePtr(astro_grav_sim_t *sim, astro_body_t bod

static astro_state_vector_t GravSimOriginState(astro_grav_sim_t *sim)
{
body_state_t *optr;
const body_state_t *optr;
astro_time_t time = sim->curr->time;

if (sim->originBody == BODY_SSB)
Expand Down Expand Up @@ -3907,7 +3907,7 @@ astro_vector_t Astronomy_HelioVector(astro_body_t body, astro_time_t time)
{
astro_vector_t vector, earth;
body_state_t bstate;
stardef_t *star;
const stardef_t *star;

star = UserDefinedStar(body);
if (star != NULL)
Expand Down Expand Up @@ -4003,7 +4003,7 @@ astro_func_result_t Astronomy_HelioDistance(astro_body_t body, astro_time_t time
{
astro_vector_t vector;
astro_func_result_t result;
stardef_t *star;
const stardef_t *star;

star = UserDefinedStar(body);
if (star != NULL)
Expand Down
10 changes: 5 additions & 5 deletions source/c/astronomy.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ static stardef_t StarTable[NSTARS];

#define GetStarPointer(body) (((body) >= BODY_STAR1) && ((body) <= BODY_STAR8) ? &StarTable[(body) - BODY_STAR1] : NULL)

static stardef_t *UserDefinedStar(astro_body_t body)
static const stardef_t *UserDefinedStar(astro_body_t body)
{
stardef_t *star = GetStarPointer(body);
const stardef_t *star = GetStarPointer(body);
if (star != NULL && star->dist > 0.0)
return star;
return NULL;
Expand Down Expand Up @@ -3974,7 +3974,7 @@ static body_state_t *GravSimBodyStatePtr(astro_grav_sim_t *sim, astro_body_t bod

static astro_state_vector_t GravSimOriginState(astro_grav_sim_t *sim)
{
body_state_t *optr;
const body_state_t *optr;
astro_time_t time = sim->curr->time;

if (sim->originBody == BODY_SSB)
Expand Down Expand Up @@ -5068,7 +5068,7 @@ astro_vector_t Astronomy_HelioVector(astro_body_t body, astro_time_t time)
{
astro_vector_t vector, earth;
body_state_t bstate;
stardef_t *star;
const stardef_t *star;

star = UserDefinedStar(body);
if (star != NULL)
Expand Down Expand Up @@ -5164,7 +5164,7 @@ astro_func_result_t Astronomy_HelioDistance(astro_body_t body, astro_time_t time
{
astro_vector_t vector;
astro_func_result_t result;
stardef_t *star;
const stardef_t *star;

star = UserDefinedStar(body);
if (star != NULL)
Expand Down

0 comments on commit 20a8459

Please sign in to comment.