diff mbox series

test-xml-encode: fix sparse NULL pointer warnings

Message ID 68a8c70e-dc42-1df3-3616-c096f63cb848@ramsayjones.plus.com (mailing list archive)
State New, archived
Headers show
Series test-xml-encode: fix sparse NULL pointer warnings | expand

Commit Message

Ramsay Jones Jan. 26, 2019, 9:03 p.m. UTC
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---

Hi Johannes,

If you need to re-roll your 'js/vsts-ci' branch, could you please
squash this into the relevant patch (commit af7747e7c7 ("tests: optionally
write results as JUnit-style .xml", 2019-01-23)).

Thanks!

ATB,
Ramsay Jones

 t/helper/test-xml-encode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Johannes Schindelin Jan. 28, 2019, 4:10 p.m. UTC | #1
Hi Ramsay,

On Sat, 26 Jan 2019, Ramsay Jones wrote:

> 
> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
> 
> Hi Johannes,
> 
> If you need to re-roll your 'js/vsts-ci' branch, could you please
> squash this into the relevant patch (commit af7747e7c7 ("tests: optionally
> write results as JUnit-style .xml", 2019-01-23)).

Certainly!

BTW would you be interested in working with me on an Azure Pipeline that
runs `sparse` on all of Junio's branches? (I am now pretty proficient with
building a software package in one Azure Pipeline, publishing it as a
build artifact, then consuming it from another Azure Pipeline, so I would
build the `sparse` package as an Ubuntu package and offer it as a build
artifact.)

I seem to recall that you once explained to me what it takes, but that
mail vanished from my inbox and I cannot find it.

Thanks,
Dscho

> 
> Thanks!
> 
> ATB,
> Ramsay Jones
> 
>  t/helper/test-xml-encode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/t/helper/test-xml-encode.c b/t/helper/test-xml-encode.c
> index 367c4875e6..a648bbd961 100644
> --- a/t/helper/test-xml-encode.c
> +++ b/t/helper/test-xml-encode.c
> @@ -26,7 +26,7 @@ int cmd__xml_encode(int argc, const char **argv)
>  		if (tmp2) {
>  			if ((ch & 0xc0) != 0x80) {
>  				fputs(utf8_replace_character, stdout);
> -				tmp2 = 0;
> +				tmp2 = NULL;
>  				cur--;
>  				continue;
>  			}
> @@ -34,7 +34,7 @@ int cmd__xml_encode(int argc, const char **argv)
>  			tmp2++;
>  			if (--remaining == 0) {
>  				fwrite(tmp, tmp2 - tmp, 1, stdout);
> -				tmp2 = 0;
> +				tmp2 = NULL;
>  			}
>  			continue;
>  		}
> -- 
> 2.20.0
>
Ramsay Jones Jan. 28, 2019, 8:13 p.m. UTC | #2
On 28/01/2019 16:10, Johannes Schindelin wrote:
> Hi Ramsay,
> 
> On Sat, 26 Jan 2019, Ramsay Jones wrote:
> 
>>
>> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
>> ---
>>
>> Hi Johannes,
>>
>> If you need to re-roll your 'js/vsts-ci' branch, could you please
>> squash this into the relevant patch (commit af7747e7c7 ("tests: optionally
>> write results as JUnit-style .xml", 2019-01-23)).
> 
> Certainly!
> 
> BTW would you be interested in working with me on an Azure Pipeline that
> runs `sparse` on all of Junio's branches? (I am now pretty proficient with
> building a software package in one Azure Pipeline, publishing it as a
> build artifact, then consuming it from another Azure Pipeline, so I would
> build the `sparse` package as an Ubuntu package and offer it as a build
> artifact.)

Happy to help, if I can.

Looking at the sparse wiki [1] we can see that the most recent
release of sparse is v0.6.0, released on December 26th 2018
(just too late for crimble!).  This is the release you will
need to use for more recent Linux distros (eg. fedora 27+,
Ubuntu 18.04, 18.10, etc).

The releases are available from [2] as a compressed tar-ball
using '.gz' or .'xz' compression. eg. sparse-0.6.0.tar.gz
(there is also a sparse-0.6.0.tar.sign).

[The git repo is at [3], BTW].

[I was a little surprised that Linux Mint 19.1 (based on Ubuntu
18.04) has v0.5.1 - Debian unstable has v0.5.2, but both of those
are just a little too old for use with git on recent Linux.]

It seems Ubuntu has split sparse into two packages, the main
'sparse' package, which contains the command-line programs and
a 'sparse-test-inspect' package, which contains the 'test-inspect'
GUI program (and so depends on GTK).

The dependencies for the 'sparse' package includes: libc6 (>= 2.14),
libllvm4.0 (>= 1:4.0~), libxml2 (>= 2.7.4), perl:any

However, for git, we only need to build 'cgcc' and 'sparse', which
means we can forget about libxml (only used for c2xml), and libllvm
(only used for sparse-llvm/sparsec/sparsei). Also, I'm not sure what
perl is doing there ...

Note that these dependencies (along with the dependent programs) are
optional and I can happily build sparse without them:

  $ make clean
  Makefile:124: Your system does not have libxml, disabling c2xml
  Makefile:146: Your system does not have gtk3/gtk2, disabling test-inspect
  Makefile:179: Your system does not have llvm, disabling sparse-llvm
    CLEAN
  $ 

Hmm, I've never built an Ubuntu package before, so I don't know
exactly what would be required (spec file etc.) to create a PPA.
But I suspect you are not talking about doing that, right?

ATB,
Ramsay Jones

[1] https://sparse.wiki.kernel.org/index.php/Main_Page
[2] http://www.kernel.org/pub/software/devel/sparse/dist/
[3] git://git.kernel.org/pub/scm/devel/sparse/sparse.git
Johannes Schindelin Jan. 28, 2019, 10:34 p.m. UTC | #3
Hi Ramsay,

On Mon, 28 Jan 2019, Ramsay Jones wrote:

> Hmm, I've never built an Ubuntu package before, so I don't know
> exactly what would be required (spec file etc.) to create a PPA.
> But I suspect you are not talking about doing that, right?

I would have gone for `checkinstall`... That still works, right?

Ciao,
Dscho
Ramsay Jones Jan. 29, 2019, 12:02 a.m. UTC | #4
On 28/01/2019 22:34, Johannes Schindelin wrote:
> Hi Ramsay,
> 
> On Mon, 28 Jan 2019, Ramsay Jones wrote:
> 
>> Hmm, I've never built an Ubuntu package before, so I don't know
>> exactly what would be required (spec file etc.) to create a PPA.
>> But I suspect you are not talking about doing that, right?
> 
> I would have gone for `checkinstall`... That still works, right?

Ah, I never think about using checkinstall - I haven't really used
it in anger. For some reason, I thought you needed to structure your
Makefile a certain way (using $DESTDIR or somesuch), but I seem to
be confusing it with something else. Apparently, no change to the
Makefile is required - it uses some kind of filesystem watcher to
note which files are copied into place by 'make install'. heh, go
figure! :-D

So, I think you only need to set the PREFIX when building (the
default installation PREFIX is $HOME), or create a local.mk file
to configure the build (I don't do that).  The 'sparse' build
does not make use of any 'auto-tools', so no configure script.

Ah, I think you will need to have pkg-config installed. I have
never built sparse from a tar-ball - I assume it works! ;-)

So (just typing into my email client - not tested):

  $ wget http://www.kernel.org/pub/software/devel/sparse/dist/sparse-0.6.0.tar.gz
  $ tar xvf sparse-0.6.0.tar.gz
  $ cd sparse-0.6.0
  $ make PREFIX=/usr/local
  $ sudo checkinstall make PREFIX=/usr/local install

... should do it. (famous last words).

ATB,
Ramsay Jones
Jonathan Nieder Jan. 29, 2019, 1:44 a.m. UTC | #5
(+cc: Uwe Kleine-König, maintainer of the sparse package in Debian)
Hi,

Ramsay Jones wrote[1]:

> Hmm, I've never built an Ubuntu package before, so I don't know
> exactly what would be required (spec file etc.) to create a PPA.
> But I suspect you are not talking about doing that, right?

Ubuntu uses the sparse packaging as is from Debian, so no PPA should
be needed.  I've sent https://bugs.debian.org/920776 to get the
package updated in Debian.  If all is well, it should go smoothly.

Thanks,
Jonathan

[1] https://public-inbox.org/git/ef5a8623-e5e6-5cc8-5178-0afce7b5499e@ramsayjones.plus.com/
Luc Van Oostenryck Jan. 29, 2019, 1:52 a.m. UTC | #6
On Mon, Jan 28, 2019 at 08:13:03PM +0000, Ramsay Jones wrote:

Hi

> The dependencies for the 'sparse' package includes: libc6 (>= 2.14),
> libllvm4.0 (>= 1:4.0~), libxml2 (>= 2.7.4), perl:any
> 
> However, for git, we only need to build 'cgcc' and 'sparse', which
> means we can forget about libxml (only used for c2xml), and libllvm
> (only used for sparse-llvm/sparsec/sparsei). Also, I'm not sure what
> perl is doing there ...

perl is only used as the interpreter of cgcc.

> 
> Note that these dependencies (along with the dependent programs) are
> optional and I can happily build sparse without them:
> 
>   $ make clean
>   Makefile:124: Your system does not have libxml, disabling c2xml
>   Makefile:146: Your system does not have gtk3/gtk2, disabling test-inspect
>   Makefile:179: Your system does not have llvm, disabling sparse-llvm
>     CLEAN
>   $ 

Absolutely.
 
-- Luc (sparse's maintainer)
Ramsay Jones Jan. 29, 2019, 2:23 a.m. UTC | #7
On 29/01/2019 01:52, Luc Van Oostenryck wrote:
> On Mon, Jan 28, 2019 at 08:13:03PM +0000, Ramsay Jones wrote:
> 
> Hi
> 
>> The dependencies for the 'sparse' package includes: libc6 (>= 2.14),
>> libllvm4.0 (>= 1:4.0~), libxml2 (>= 2.7.4), perl:any
>>
>> However, for git, we only need to build 'cgcc' and 'sparse', which
>> means we can forget about libxml (only used for c2xml), and libllvm
>> (only used for sparse-llvm/sparsec/sparsei). Also, I'm not sure what
>> perl is doing there ...
> 
> perl is only used as the interpreter of cgcc.

heh, yeah (palm-face), I was only thinking about _build_ dependency! :-D

ATB,
Ramsay Jones
diff mbox series

Patch

diff --git a/t/helper/test-xml-encode.c b/t/helper/test-xml-encode.c
index 367c4875e6..a648bbd961 100644
--- a/t/helper/test-xml-encode.c
+++ b/t/helper/test-xml-encode.c
@@ -26,7 +26,7 @@  int cmd__xml_encode(int argc, const char **argv)
 		if (tmp2) {
 			if ((ch & 0xc0) != 0x80) {
 				fputs(utf8_replace_character, stdout);
-				tmp2 = 0;
+				tmp2 = NULL;
 				cur--;
 				continue;
 			}
@@ -34,7 +34,7 @@  int cmd__xml_encode(int argc, const char **argv)
 			tmp2++;
 			if (--remaining == 0) {
 				fwrite(tmp, tmp2 - tmp, 1, stdout);
-				tmp2 = 0;
+				tmp2 = NULL;
 			}
 			continue;
 		}