aboutsummaryrefslogtreecommitdiff
path: root/src/PJ_unitconvert.c
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-05-29 22:45:18 +0200
committerEven Rouault <even.rouault@spatialys.com>2018-05-30 11:48:28 +0200
commitf773897a3025438326c1131e1586d9ddae080c4f (patch)
tree989e9619ac1f1ad140298bef5327df3f2d417d92 /src/PJ_unitconvert.c
parente692e1567fb6117bd3e1380a80e10b72b7af3710 (diff)
downloadPROJ-f773897a3025438326c1131e1586d9ddae080c4f.tar.gz
PROJ-f773897a3025438326c1131e1586d9ddae080c4f.zip
Fix warnings found by clang with new warning flags to be added in later commit
Fixes consist in: - no use of comma operator for multi statement purpose - avoid confusing comma in for loops first and third clauses - avoid implicit long to int casts by storing to long, or explicit bound checking before cast
Diffstat (limited to 'src/PJ_unitconvert.c')
-rw-r--r--src/PJ_unitconvert.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/PJ_unitconvert.c b/src/PJ_unitconvert.c
index a3051ad7..25bdc2e7 100644
--- a/src/PJ_unitconvert.c
+++ b/src/PJ_unitconvert.c
@@ -94,20 +94,20 @@ struct pj_opaque_unitconvert {
/***********************************************************************/
-static int is_leap_year(int year) {
+static int is_leap_year(long year) {
/***********************************************************************/
return ((year % 4 == 0 && year % 100 != 0) || year % 400 ==0);
}
/***********************************************************************/
-static int days_in_year(int year) {
+static int days_in_year(long year) {
/***********************************************************************/
return is_leap_year(year) ? 366 : 365;
}
/***********************************************************************/
-static unsigned int days_in_month(unsigned int year, unsigned int month) {
+static unsigned int days_in_month(unsigned long year, unsigned long month) {
/***********************************************************************/
const unsigned int month_table[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
unsigned int days;
@@ -123,7 +123,7 @@ static unsigned int days_in_month(unsigned int year, unsigned int month) {
/***********************************************************************/
-static int daynumber_in_year(unsigned int year, unsigned int month, unsigned int day) {
+static int daynumber_in_year(unsigned long year, unsigned long month, unsigned long day) {
/***********************************************************************/
unsigned int daynumber=0, i;
@@ -167,7 +167,7 @@ static double decimalyear_to_mjd(double decimalyear) {
year = lround(floor(decimalyear));
fractional_year = decimalyear - year;
mjd = (year - 1859)*365 + 14 + 31;
- mjd += fractional_year*days_in_year(year);
+ mjd += (double)fractional_year*(double)days_in_year(year);
/* take care of leap days */
year--;