Patch for ticket #457 (air temp and water temp not changing)

Dirk Hohndel dirk at hohndel.org
Wed Mar 12 15:59:07 PDT 2014


On Wed, 2014-03-12 at 22:50 +0200, Gehad Elrobey wrote:
> Hello all,
> 
> I am sending the patch for ticket #457
> 
> 
> 
> now the water temp and air temp can be changed if the dive value is
> not equals zero.
> 
> Please let me know if there is any feedback.

I believe the logic of the patch is incorrect.

> From: Gehad elrobey <gehadelrobey at gmail.com>
> Date: Wed, 12 Mar 2014 22:14:58 +0200
> Subject: [PATCH] Fixing airtemp watertemp to change more than 1 time
> 
> The if condition changes the value to a new one only when is equal to
> zero. the condition is changed to check if the pointer is not pointing
> to null

we know that the pointer is not NULL. Both functions are called from
fixup_dive() which is only called with a valid dive.

But the check in the if statement actually does something else.
It says "if there is no temperature set for the dive, then fill this
value based on the values set by the dive computer(s). But if there
already IS a value set on the dive, don't mess with it. This is for
backwards compatibility with old versions of Subsurface where that
temperature was set in the dive structure (before we had the dive
computer structures) and exactly to be able to set a water temperature /
air temperature on the dive without changing the values stored in the
dive computer structure(s).

What I think you need to track down is why this only gets changed the
first time around but not on subsequent edits.

/D




> Signed-off-by: Gehad elrobey <gehadelrobey at gmail.com>
> ---
>  dive.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/dive.c b/dive.c
> index 6deee8b..185087b 100644
> --- a/dive.c
> +++ b/dive.c
> @@ -719,7 +719,7 @@ unsigned int dc_watertemp(struct divecomputer *dc)
>  
>  static void fixup_watertemp(struct dive *dive)
>  {
> -    if (!dive->watertemp.mkelvin)
> +    if (dive)
>          dive->watertemp.mkelvin = dc_watertemp(&dive->dc);
>  }
>  
> @@ -743,7 +743,7 @@ unsigned int dc_airtemp(struct divecomputer *dc)
>  
>  static void fixup_airtemp(struct dive *dive)
>  {
> -    if (!dive->airtemp.mkelvin)
> +    if (dive)
>          dive->airtemp.mkelvin = dc_airtemp(&dive->dc);
>  }
>  
> -- 
> 1.8.3.2






More information about the subsurface mailing list