lib/util: Count a trailing line that doesn't end in a newline
authorMartin Schwenke <martin@meltin.net>
Fri, 14 Dec 2018 03:43:57 +0000 (14:43 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 19 Dec 2018 07:08:28 +0000 (08:08 +0100)
commit5118985841aa0363147d552f243ab5a7d90dbdaf
tree71525a4b321de0aadf58e6c11eeb2ffdbb8046c7
parentb3e4e094261c039320f6ad999043f78695e56021
lib/util: Count a trailing line that doesn't end in a newline

If the final line of a file does not contain a newline then it isn't
included in the line count.

Change i to point to the next slot in the array instead of the current
one.  This means that that the current line won't be thrown away if no
newline is seen.

Without changing i to unsigned int, the -O3 --picky -developer build
fails with:

[ 745/4136] Compiling lib/util/util_file.c

==> /builds/samba-team/devel/samba/samba-o3.stderr <==
../../lib/util/util_file.c: In function ‘file_lines_parse’:
../../lib/util/util_file.c:251:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
  while (i > 0 && ret[i-1][0] == 0) {
        ^
cc1: all warnings being treated as errors

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13717

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Dec 19 08:08:28 CET 2018 on sn-devel-144
lib/util/tests/file.c
lib/util/util_file.c