<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-09-17 17:06 GMT+02:00 Dirk Hohndel <span dir="ltr"><<a href="mailto:dirk@hohndel.org" target="_blank">dirk@hohndel.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ok, let's talk about learning :-)<br>
<br>
On Thu, Sep 17, 2015 at 04:51:33PM +0200, Guido Lerch wrote:<br>
> From cd5c20831b006fcb5da6397301026ac056fa949d Mon Sep 17 00:00:00 2001<br>
> From: glerch <<a href="mailto:guido.lerch@gmail.com">guido.lerch@gmail.com</a>><br>
> Date: Thu, 17 Sep 2015 16:46:02 +0200<br>
> Subject: [PATCH 7/7] UEMIS-fix alternating dive details<br>
<br>
I am rewriting the subject of most of your commits to fit the pattern:<br>
<br>
Uemis divelog: ..... (starting with lower case)<br>
<br>
> Implemented suggestion from Dir on how to deal with dive details<br>
                             ^^^^^<br>
> not being found.<br>
<br>
Proof-reading :-)<br></blockquote><div><br></div><div>hä ? </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> I also cleaned up some unused variables, got rid of the last_log_file_nr<br>
> because it's not needed anymore.<br>
<br>
Should this have been two commits? Maybe not.<br>
<br>
> I kept the UEMIS_DEBUG flags active on purpose.<br>
<br>
Don't. Ideally they should just be passed in when calling cmake:<br>
<br>
CFLAGS=-DUEMIS_DEBUG=7 cmake .<br></blockquote><div><br></div><div>THANKS, I was waiting for this tip without actually ever asking directly :-) </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If you really want them in the C file for your tests then remove them<br>
before you send patches to me.<br>
><br>
> One thing ins question I still need to check and this is whether we really<br>
            ^^^<br>
            proof reading<br>
<br>
> need to decrease the dive_to_read if we find deleted dive details, this is<br>
> still in but I dont think it's really needed.<br>
><br>
> Signed-off-by: glerch <<a href="mailto:guido.lerch@gmail.com">guido.lerch@gmail.com</a>><br>
> ---<br>
>  uemis-downloader.c | 51 ++++++++++++++++++++++++++-------------------------<br>
>  1 file changed, 26 insertions(+), 25 deletions(-)<br>
><br>
> diff --git a/uemis-downloader.c b/uemis-downloader.c<br>
> index 0981f4b..43bda9b 100644<br>
> --- a/uemis-downloader.c<br>
> +++ b/uemis-downloader.c<br>
> @@ -31,7 +31,7 @@<br>
>  #define NUM_PARAM_BUFS 10<br>
><br>
>  // debugging setup<br>
> -// #define UEMIS_DEBUG 1 + 2 + 4 + 8 + 16 + 32<br>
> +#define UEMIS_DEBUG 1 + 2 + 4<br>
><br>
>  #define UEMIS_MAX_FILES 4000<br>
>  #define UEMIS_MEM_FULL 1<br>
> @@ -69,6 +69,7 @@ static int mbuf_size = 0;<br>
><br>
>  static int max_mem_used = -1;<br>
>  static int next_table_index = 0;<br>
> +static int dive_to_read = 0;<br>
><br>
>  /* helper function to parse the Uemis data structures */<br>
>  static void uemis_ts(char *buffer, void *_when)<br>
> @@ -367,7 +368,7 @@ static void buffer_add(char **buffer, int *buffer_size, char *buf)<br>
>               *buffer = realloc(*buffer, *buffer_size);<br>
>               strcat(*buffer, buf);<br>
>       }<br>
> -#if UEMIS_DEBUG & 16<br>
> +#if UEMIS_DEBUG & 8<br>
<br>
Stuff like this mixed into a patch makes it much harder to see what you<br>
are actually changing in the patch. That's why I encourage you to do<br>
smaller commits that do just one thing.<br></blockquote><div><br></div><div>I know, I was rushing though as I wanted this out, with proper testing, before I leave on Saturday. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If you look at everything above, the only real change is yet another<br>
global variable that you added.<br>
<br>
And it continues like this, the next two hunks are also just noise.<br>
<br>
> -                                     /* Ugly, need something better than this<br>
> -                                      * essentially, if we start reading divelogs not from the start<br>
> -                                      * we have no idea on how many log entries are there that have no<br>
> -                                      * valid dive details */<br>
> -                                     if (*dive_to_read >= dive->dc.diveid)<br>
> -                                             *dive_to_read = (*dive_to_read - 2 >= 0 ? *dive_to_read - 2 : 0);<br>
> +                                     uint32_t nr_found = 0;<br>
> +                                     char *logfilenr = strstr(mbuf, "logfilenr");<br>
> +                                     if (logfilenr) {<br>
> +                                             sscanf(logfilenr, "logfilenr{int{%u", &nr_found);<br>
> +                                             if (nr_found >= dive->dc.diveid)<br>
> +                                                     dive_to_read = dive_to_read - 2;<br>
> +                                             if (dive_to_read < -1)<br>
> +                                                     dive_to_read = -1;<br>
> +                                     }<br>
>                               }<br>
>                       }<br>
> -                     *dive_to_read = *dive_to_read + 1;<br>
> +                     dive_to_read++;<br>
<br>
Yep, that should work with my Uemis. I'll test it next.<br>
<br>
And I'll take your commit as it is (minus the part where you turn on<br>
debugging by default). So no need to resubmit.<br>
<span class="HOEnZb"><font color="#888888"><br>
/D<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Best regards,<div>Guido</div></div></div>
</div></div>