[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 5336d5c 024/125: Small but important correctio
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 5336d5c 024/125: Small but important corrections |
Date: |
Sun, 23 Apr 2017 22:36:29 -0400 (EDT) |
branch: master
commit 5336d5c3a639ef01eb0e6adf886e04d67f784628
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Small but important corrections
Some small points that had been missed during writing of the code has been
corrected. These are mostly one-liners, but would cause crashes or infinite
loops.
---
bin/arithmetic/arithmetic.c | 2 --
bin/arithmetic/operands.c | 9 ++++-----
lib/data-arithmetic-other.c | 3 +--
lib/data.c | 4 ++--
4 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index 5b75361..8e4895a 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -284,7 +284,6 @@ reversepolish(struct imgarithparams *p)
else if (!strcmp(token->v, "double"))
{ op=GAL_DATA_OPERATOR_TO_DOUBLE; nop=1; }
-
/* Finished checks with known operators */
else
error(EXIT_FAILURE, 0, "the argument \"%s\" could not be "
@@ -381,7 +380,6 @@ reversepolish(struct imgarithparams *p)
gal_data_free(d1);
free(p->refdata.dsize);
-
/* Clean up. Note that the tokens were taken from the command-line
arguments, so the string within each token linked list must not be
freed. */
diff --git a/bin/arithmetic/operands.c b/bin/arithmetic/operands.c
index d18754e..eea13c9 100644
--- a/bin/arithmetic/operands.c
+++ b/bin/arithmetic/operands.c
@@ -60,11 +60,10 @@ add_operand(struct imgarithparams *p, char *filename,
gal_data_t *data)
{
struct operand *newnode;
- /* Some operators might not actually return any dataset (for example the
- multi-operand datasets when the number of operands is 0, which can
- happen in a script), in such cases, we shouldn't add anything to the
- stack. */
- if(data)
+ /* Some operators might not actually return any dataset (data=NULL), in
+ such cases filename will also be NULL (since the operand was not added
+ from the command-line). So, we shouldn't add anything to the stack. */
+ if(data || filename)
{
/* Allocate space for the new operand. */
errno=0;
diff --git a/lib/data-arithmetic-other.c b/lib/data-arithmetic-other.c
index 8c7d9bb..ed12c7d 100644
--- a/lib/data-arithmetic-other.c
+++ b/lib/data-arithmetic-other.c
@@ -47,7 +47,7 @@ gal_data_t *
data_arithmetic_change_type(gal_data_t *data, int operator,
unsigned char flags)
{
- int type=0;
+ int type=-1;
gal_data_t *out;
/* Set the output type. */
@@ -64,7 +64,6 @@ data_arithmetic_change_type(gal_data_t *data, int operator,
case GAL_DATA_OPERATOR_TO_LONGLONG: type=GAL_DATA_TYPE_LONGLONG; break;
case GAL_DATA_OPERATOR_TO_FLOAT: type=GAL_DATA_TYPE_FLOAT; break;
case GAL_DATA_OPERATOR_TO_DOUBLE: type=GAL_DATA_TYPE_DOUBLE; break;
-
default:
error(EXIT_FAILURE, 0, "operator value of %d not recognized in "
"`data_arithmetic_change_type'", operator);
diff --git a/lib/data.c b/lib/data.c
index 41dd5fc..0086537 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -1011,7 +1011,7 @@ gal_data_has_blank(gal_data_t *data)
"datatype, please get in touch with us to implement it.");
case GAL_DATA_TYPE_UCHAR:
- do if(*uc==GAL_DATA_BLANK_UCHAR) return 1; while(uc<ucf);
+ do if(*uc++==GAL_DATA_BLANK_UCHAR) return 1; while(uc<ucf);
break;
@@ -2003,7 +2003,7 @@ gal_data_arithmetic(int operator, unsigned char flags,
...)
case GAL_DATA_OPERATOR_TO_FLOAT:
case GAL_DATA_OPERATOR_TO_DOUBLE:
d1 = va_arg(va, gal_data_t *);
- data_arithmetic_change_type(d1, operator, flags);
+ out=data_arithmetic_change_type(d1, operator, flags);
break;
- [gnuastro-commits] master updated (a5aeb7d -> 3339b92), Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master 3e05560 003/125: Corrected bad use of type in MakeProfiles, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master 847d97e 007/125: Minor header inclusion corrections, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master 591461c 015/125: Corrected occurance of "remainder" with modulo, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master 1ea9ea2 009/125: Data structure mmap information updated, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master 531c263 008/125: Operators treated as macros, not string, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master ff9258a 006/125: Arithmetic with internal type conversion, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master 5336d5c 024/125: Small but important corrections,
Mohammad Akhlaghi <=
- [gnuastro-commits] master c2fcb3e 020/125: Absolute value operator in gal_data_arithmetic, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master fdb6183 019/125: Where operator implemented in gal_data_arithmetic, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master 493bc6f 001/125: Defined new gnuastro/data.h header, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master c6462d1 016/125: Type conversion operators in Arithmetic, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master c10c4be 002/125: Moved type code and alloc functions into data.h, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master a4c5b9d 012/125: Binary operator arithmetic works on uncompiled types, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master ad2810d 029/125: Work started on getting text table information, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master bc57ade 021/125: Minimum and maximum value operators implemented, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master 2dea9a7 011/125: All binary operator types set at configure time, Mohammad Akhlaghi, 2017/04/23
- [gnuastro-commits] master ff0b76d 018/125: New Data types section in book, bitwise not added, Mohammad Akhlaghi, 2017/04/23