From 2f602eedd6efb5db85a77eede193f0f47418e537 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 22 Nov 2013 11:27:29 +0000 Subject: [PATCH] clang static analyze notes --- README.md | 12 +++++------- tools/find_mosaic.c | 26 +++++++++++++++----------- tools/mergeup.c | 28 +++++++++++++++------------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index d0b92e7f..23b1b752 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,11 @@ Clang build: $ CC=clang CXX=clang++ ./configure --prefix=/home/john/vips +Clang static analysis: + + $ CC=... scan-build ./configure ... + $ scan-build -o scan -v make + Clang dynamic analysis: $ CC=clang CXX=clang++ LD=clang \ @@ -68,13 +73,6 @@ Clang dynamic analysis: LDFLAGS="-fsanitize=thread -pie" \ ./configure --prefix=/home/john/vips --disable-introspection -Clang static analysis: - - $ configure as you please - $ scan-build -o scan make ... - - - # Dependencies libvips has to have gettext, glib-2.x and libxml-2.0. The build system needs diff --git a/tools/find_mosaic.c b/tools/find_mosaic.c index 530482bd..1581e5b9 100644 --- a/tools/find_mosaic.c +++ b/tools/find_mosaic.c @@ -132,11 +132,13 @@ char *name; /* Find the x position of a file name (extract n from .nxm.v). */ static int -find_x( name ) -char *name; -{ int n; +find_x( char *name ) +{ + int n; char *p; - char *out = strdup( name ); + char *out; + + out = strdup( name ); /* Chop off '.v'. */ @@ -166,17 +168,21 @@ char *name; return( -1 ); } + free( out ); + return( n ); } /* Find the y position of a file name (extract m from .nxm.v). */ static int -find_y( name ) -char *name; -{ int m; +find_y( char *name ) +{ + int m; char *p; - char *out = strdup( name ); + char *out; + + out = strdup( name ); /* Chop off '.v'. */ @@ -207,12 +213,10 @@ char *name; } free( out ); + return( m ); } - - - static int mosaic_analysis(int width, int height,IMAGE **inp, IMAGE *out, int xoff, int yoff, int *vxdisp, int *vydisp,int *hxdisp, int *hydisp) { diff --git a/tools/mergeup.c b/tools/mergeup.c index d1b11de4..c87ba186 100644 --- a/tools/mergeup.c +++ b/tools/mergeup.c @@ -258,11 +258,13 @@ char *name; /* Find the x position of a file name (extract n from .nxm.v). */ static int -find_x( name ) -char *name; -{ int n; +find_x( char *name ) +{ + int n; char *p; - char *out = strdup( name ); + char *out; + + out = strdup( name ); /* Chop off '.v'. */ @@ -292,17 +294,21 @@ char *name; return( -1 ); } + free( out ); + return( n ); } /* Find the y position of a file name (extract m from .nxm.v). */ static int -find_y( name ) -char *name; -{ int m; +find_y( char *name ) +{ + int m; char *p; - char *out = strdup( name ); + char *out; + + out = strdup( name ); /* Chop off '.v'. */ @@ -333,14 +339,10 @@ char *name; } free( out ); + return( m ); } - - - - - /* Join two frames left-right. Have to open them and find their sizes. */ static int