Skip to content

Commit

Permalink
Fixes to (most) clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Jan 12, 2025
1 parent 54a1ca4 commit 11f3c0e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 28 deletions.
8 changes: 3 additions & 5 deletions src/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

// We'll use gcc major version as a proxy for the glibc library to decide which feature macro to use.
// gcc 5.1 was released 2015-04-22...
#ifndef __GNUC__
# define _DEFAULT_SOURCE ///< strcasecmp() feature macro starting glibc 2.20 (2014-09-08)
#elif __GNUC__ >= 5
# define _DEFAULT_SOURCE ///< strcasecmp() feature macro starting glibc 2.20 (2014-09-08)
#else
#if defined(__GNUC__) && (__GNUC__ < 5)
# define _BSD_SOURCE ///< strcasecmp() feature macro for glibc <= 2.19
#else
# define _DEFAULT_SOURCE ///< strcasecmp() feature macro starting glibc 2.20 (2014-09-08)
#endif

#include <math.h>
Expand Down
2 changes: 0 additions & 2 deletions test/src/test-calceph.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* @file
*
* @date Created on Feb 18, 2024
* @author Attila Kovacs
*/
Expand Down
2 changes: 0 additions & 2 deletions test/src/test-cio_file.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* @file
*
* @date Created on Feb 16, 2024
* @author Attila Kovacs
*/
Expand Down
6 changes: 2 additions & 4 deletions test/src/test-compat.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* @file
*
* @date Created on Jan 30, 2024
* @author Attila Kovacs
*/
Expand Down Expand Up @@ -671,7 +669,7 @@ static void test_light_time() {
static void test_grav_def() {
double pos1[3], pos2[3], ps[3], vs[3];
double d, jd2[2] = { tdb };
object sun = { 0, 10, "Sun" };
object sun = NOVAS_SUN_INIT;
int k;

if(source.type != 2) return;
Expand Down Expand Up @@ -1081,7 +1079,7 @@ static int test_accuracy() {
}


int main(int argc, char *argv[]) {
int main() {
test_basics();
test_accuracy();
fprintf(fp, "\n");
Expand Down
2 changes: 0 additions & 2 deletions test/src/test-cspice.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* @file
*
* @date Created on Feb 18, 2024
* @author Attila Kovacs
*/
Expand Down
8 changes: 5 additions & 3 deletions test/src/test-errors.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* @file
*
* @date Created on Feb 19, 2024
* @author Attila Kovacs
*/
Expand Down Expand Up @@ -1120,6 +1118,10 @@ static int test_time() {

static double switching_refraction(double jd_tt, const on_surface *loc, enum novas_refraction_type type, double el) {
static int count;
(void) jd_tt;
(void) loc;
(void) type;
(void) el;
return (count++) % 2 ? -0.1 : 0.1;
}

Expand Down Expand Up @@ -1199,7 +1201,7 @@ static int test_change_observer() {
if(check("change_observer:obs", -1, novas_change_observer(&frame, NULL, &out))) n++;
if(check("change_observer:out", -1, novas_change_observer(&frame, &obs, NULL))) n++;

return 0;
return n;
}

static int test_make_transform() {
Expand Down
23 changes: 13 additions & 10 deletions test/src/test-super.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
/**
* @file
*
* @date Created on Feb 18, 2024
* @author Attila Kovacs
*/


// We'll use gcc major version as a proxy for the glibc library to decide which feature macro to use.
// gcc 5.1 was released 2015-04-22...
#ifndef __GNUC__
# define _DEFAULT_SOURCE ///< strcasecmp() feature macro starting glibc 2.20 (2014-09-08)
#elif __GNUC__ >= 5
# define _DEFAULT_SOURCE ///< strcasecmp() feature macro starting glibc 2.20 (2014-09-08)
#else
#if defined(__GNUC__) && (__GNUC__ < 5)
# define _BSD_SOURCE ///< strcasecmp() feature macro for glibc <= 2.19
#else
# define _DEFAULT_SOURCE ///< strcasecmp() feature macro starting glibc 2.20 (2014-09-08)
#endif

#include <stdio.h>
Expand Down Expand Up @@ -47,6 +43,8 @@ static double pos0[3];
static enum novas_origin ephem_origin;

static short dummy_planet_hp(const double *jd_tdb, enum novas_planet body, enum novas_origin origin, double *position, double *velocity) {
(void) jd_tdb;
(void) origin;
memset(position, 0, 3 * sizeof(double));
memset(velocity, 0, 3 * sizeof(double));
position[0] = body % 10;
Expand All @@ -56,10 +54,14 @@ static short dummy_planet_hp(const double *jd_tdb, enum novas_planet body, enum

static short dummy_planet(double jd_tdb, enum novas_planet body, enum novas_origin origin, double *position, double *velocity) {
double tdb2[2] = { tdb };
(void) jd_tdb;
return dummy_planet_hp(tdb2, body, origin, position, velocity);
}

static int dummy_ephem(const char *name, long id, double jd_tdb_high, double jd_tdb_low, enum novas_origin *origin, double *pos, double *vel) {
(void) name;
(void) jd_tdb_high;
(void) jd_tdb_low;
*origin = ephem_origin;
memset(pos, 0, 3 * sizeof(double));
memset(vel, 0, 3 * sizeof(double));
Expand Down Expand Up @@ -1792,7 +1794,7 @@ static int test_unix_time() {
printf("!!! sec: %ld %ld\n", (long) novas_get_unix_time(&t, &nsec), sec);
return 1;
}
if(!is_ok("sunix_time:check:nsec", abs(nsec - nanos) > 0)) {
if(!is_ok("sunix_time:check:nsec", labs(nsec - nanos) > 0)) {
printf("!!! nsec %ld %ld\n", nsec, nanos);
return 1;
}
Expand All @@ -1809,7 +1811,7 @@ static int test_unix_time() {
printf("!!! sec: %ld %ld\n", (long) novas_get_unix_time(&t, &nsec), (long) sec);
return 1;
}
if(!is_ok("unix_time:offset:check:incr:nsec", abs(nsec - nanos) > 0)) {
if(!is_ok("unix_time:offset:check:incr:nsec", labs(nsec - nanos) > 0)) {
printf("!!! nsec %ld %ld\n", nsec, nanos);
return 1;
}
Expand All @@ -1820,7 +1822,7 @@ static int test_unix_time() {
printf("!!! sec: %ld %ld\n", (long) novas_get_unix_time(&t, &nsec), (long) sec);
return 1;
}
if(!is_ok("unix_time:neg:check:nsec", abs(nsec - nanos) > 0)) {
if(!is_ok("unix_time:neg:check:nsec", labs(nsec - nanos) > 0)) {
printf("!!! nsec %ld %ld\n", nsec, nanos);
return 1;
}
Expand Down Expand Up @@ -2424,6 +2426,7 @@ static int test_orbit_posvel_callisto() {
int main(int argc, char *argv[]) {
int n = 0;

(void) argc;
workPath = dirname(argv[0]);

novas_debug(NOVAS_DEBUG_ON);
Expand Down

0 comments on commit 11f3c0e

Please sign in to comment.