[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 84150db: Unified numeric type for MakeProfiles
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 84150db: Unified numeric type for MakeProfiles function codes |
Date: |
Fri, 14 Jul 2017 13:54:41 -0400 (EDT) |
branch: master
commit 84150db6872a79641a509a42cd52f08fd30abb50
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Unified numeric type for MakeProfiles function codes
Gnuastro 0.3.23 fails on big-endian systems in the Debian builds (you can
click on the red "Build attempted" signs to see the log of the whole
build. This is the error:
bin/mkprof/.libs/astmkprof: ../tests/mkprof/mkprofcat2.txt: table row 1,
the function code is 0. It should be >0 and <7. Please run again with
`--help' and check the acceptable codes.
The reason of the problem was that we were treating the function codes as a
8-bit integers in some places, and 32-bit integers in others. Since there
is only 6 profiles currently (profile codes between 1 and 7), only the
smallest byte was actually being filled.
On little-endian systems (most commonly used systems including mine), the
smallest byte is placed first, so reading a 32-bit integer as an 8-bit
integer worked successfully and there was no problem. But on big-endian
systems, only the last byte is filled and so the first byte was being read
as 0.
To fix the issue, all the cases we deal with function codes have been
unified to `uint8_t' with this commit (allowing a maximum of 255 function
types).
This fixes bug #51467.
---
NEWS | 2 ++
bin/mkprof/mkprof.h | 2 +-
bin/mkprof/oneprofile.c | 4 ++--
bin/mkprof/oneprofile.h | 2 +-
bin/mkprof/ui.c | 8 ++++----
5 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/NEWS b/NEWS
index 4239b40..194250d 100644
--- a/NEWS
+++ b/NEWS
@@ -83,6 +83,8 @@ GNU Astronomy Utilities NEWS -*-
outline -*-
Pixel scale measurement when dimension scale isn't equal or doesn't
decrease (bug #51385).
+ Inproper types for function code in MakeProfiles (bug #51467).
+
diff --git a/bin/mkprof/mkprof.h b/bin/mkprof/mkprof.h
index 8264317..b786d78 100644
--- a/bin/mkprof/mkprof.h
+++ b/bin/mkprof/mkprof.h
@@ -48,7 +48,7 @@ struct mkonthread
long width[2]; /* Enclosing box in FITS axes, not C. */
float peakflux; /* Flux at profile peak. */
float brightness; /* The brightness of the profile. */
- int func; /* Radial function of the profile. */
+ uint8_t func; /* Radial function of the profile. */
long *onaxes; /* Sides of the unover-sampled image. */
long fpixel_i[2]; /* fpixel_i before running overlap. */
int correction; /* ==1: correct the pixels afterwards. */
diff --git a/bin/mkprof/oneprofile.c b/bin/mkprof/oneprofile.c
index 6996d3b..e36385a 100644
--- a/bin/mkprof/oneprofile.c
+++ b/bin/mkprof/oneprofile.c
@@ -386,7 +386,7 @@ makepixbypix(struct mkonthread *mkp)
/************ Set profile parameters *************/
/**************************************************************/
int
-oneprofile_ispsf(int fcode)
+oneprofile_ispsf(uint8_t fcode)
{
return fcode==PROFILE_MOFFAT || fcode==PROFILE_GAUSSIAN;
}
@@ -510,7 +510,7 @@ oneprof_set_prof_params(struct mkonthread *mkp)
default:
error(EXIT_FAILURE, 0, "%s: a bug! Please contact us so we can correct "
- "this problem. The profile code %d is not recognized.", __func__,
+ "this problem. The profile code %u is not recognized.", __func__,
mkp->func);
}
}
diff --git a/bin/mkprof/oneprofile.h b/bin/mkprof/oneprofile.h
index e04f85b..08cc19c 100644
--- a/bin/mkprof/oneprofile.h
+++ b/bin/mkprof/oneprofile.h
@@ -26,7 +26,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include "mkprof.h"
int
-oneprofile_ispsf(int fcolvalue);
+oneprofile_ispsf(uint8_t fcolvalue);
void
oneprof_set_prof_params(struct mkonthread *mkp);
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index ecd1cd4..d7e1bb3 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -109,7 +109,7 @@ enum program_args_groups
/**************************************************************/
/********* Initialize & Parse command-line **************/
/**************************************************************/
-static int
+static uint8_t
ui_profile_name_read(char *string, size_t row)
{
if( !strcmp("sersic", string) )
@@ -688,7 +688,7 @@ ui_read_cols(struct mkprofparams *p)
case 1:
if(tmp->type==GAL_TYPE_STRING)
{
- p->f=gal_data_malloc_array(GAL_TYPE_INT32, p->num,
+ p->f=gal_data_malloc_array(GAL_TYPE_UINT8, p->num,
__func__, "p->f");
strarr=tmp->array;
for(i=0;i<p->num;++i)
@@ -700,14 +700,14 @@ ui_read_cols(struct mkprofparams *p)
{
/* Read the user's profile codes. */
colname="profile function code (`fcol')";
- corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_INT32);
+ corrtype=gal_data_copy_to_new_type_free(tmp, GAL_TYPE_UINT8);
p->f=corrtype->array;
/* Check if they are in the correct range. */
for(i=0;i<p->num;++i)
if(p->f[i]<=PROFILE_INVALID || p->f[i]>=PROFILE_MAXIMUM_CODE)
error(EXIT_FAILURE, 0, "%s: table row %zu, the function "
- "code is %d. It should be >%d and <%d. Please run "
+ "code is %u. It should be >%d and <%d. Please run "
"again with `--help' and check the acceptable "
"codes.\n\nAlternatively, you can use alphabetic "
"strings to specify the profile functions, see the "
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master 84150db: Unified numeric type for MakeProfiles function codes,
Mohammad Akhlaghi <=