Re: [PATCH] Check SHA256 sum of git-$VER.tar.gz after downloading

2015-03-08 Thread John Keeping
On Sat, Mar 07, 2015 at 06:35:10PM -0500, Todd Zullinger wrote:
 John Keeping wrote:
  I still think we can't rely on `gpg --recv-keys` though, we would 
  have to distribute the key with CGit and possible also do something 
  to avoid importing it into the user's keyring by default.
 
 If the check was to be run from a cgit clone, the key Junio uses to 
 sign git tarballs could be included as a blob, similarly to how it's 
 done in git.git.

My assumption is that if people have cloned CGit then they will probably
clone Git as well, at which point they check out an explicit SHA-1.

 (See the junio-gpg-pub tag in git.git for anyone unfamiliar with this 
 already.  The key can be extracted via:
 
 git cat-file blob junio-gpg-pub
 
 I've always thought that was a neat use of git, but certainly not a 
 common one.  I can't manage to make github display this tagged blob, 
 which is also amusing.
 
 The cgit-hosted kernel.org repo displays it easily though:
 
 http://git.kernel.org/cgit/git/git.git/tag/?id=junio-gpg-pub)
 
 This method does nothing for users who have downloaded a cgit tarball, 
 of course, which I expect is more likely to be the use case you're 
 targeting.

Precisely.

  I think a hash is more appropriate for the situation we're in - we 
  are assuming that the user is happy that the CGit distribution they 
  have is trustworthy but we must verify that the Git distribution we 
  download is also correct.
 
 I don't think this is unreasonable at all.  Trust has to start 
 somewhere.  For users that want to go to the source, they can always 
 download git directly (or just the detached PGP signature) and verify 
 the tarball.  When I updated cgit packages in Fedora and EPEL, this is 
 what I always did.  I don't know if the current maintainers follow 
 that process still, but hopefully they do. ;)
 
 But while we're on the subject, are there PGP signatures available for 
 the cgit tarballs themselves?  I know the git tags are signed, but I 
 don't think I've seen detached signatures for the tarballs.  In this 
 case, how does a user become happy that the CGit distribution they 
 have is trustworthy?  The cgit tarball download isn't available via 
 https either, which might be a reasonable answer in the absence of a 
 detached git signature.
 
 Without a signature on the tarball or some other method to verify the 
 cgit tarball, the sha256 of the git tarball included in the cgit 
 Makefile is more or less only useful as a basic download integrity 
 check (in which case sha256 is mild overkill).
 
 None of this is to say that this patch isn't a step in the right 
 direction.  It certainly helps to display a nicer error message if a 
 user receives a corrupted git tarball.  It's just important that users 
 don't confuse this with providing any real authentication of the git 
 tarball.

I'm not sure this is true.  Providing that the CGit tarball is trusted,
then I think this does provide sufficient authentication of the Git
tarball.  If the CGit tarball isn't trusted, then all bets are off
anyway.
___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 02/13] Avoid non-ANSI function declarations

2015-03-08 Thread John Keeping
Sparse says things like:

warning: non-ANSI function declaration of function 'calc_ttl'

Signed-off-by: John Keeping j...@keeping.me.uk
---
 cgit.c|  2 +-
 filter.c  |  2 +-
 ui-diff.c |  2 +-
 ui-refs.c |  4 ++--
 ui-repolist.c |  6 +++---
 ui-shared.c   | 12 ++--
 ui-ssdiff.c   | 16 
 ui-summary.c  |  2 +-
 ui-tree.c |  4 ++--
 9 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/cgit.c b/cgit.c
index 0ad8171..c16ed8c 100644
--- a/cgit.c
+++ b/cgit.c
@@ -1013,7 +1013,7 @@ static void cgit_parse_args(int argc, const char **argv)
}
 }
 
-static int calc_ttl()
+static int calc_ttl(void)
 {
if (!ctx.repo)
return ctx.cfg.cache_root_ttl;
diff --git a/filter.c b/filter.c
index 9f433db..ebf4937 100644
--- a/filter.c
+++ b/filter.c
@@ -72,7 +72,7 @@ static inline void hook_write(struct cgit_filter *filter, 
ssize_t (*new_write)(s
filter_write = new_write;
 }
 
-static inline void unhook_write()
+static inline void unhook_write(void)
 {
assert(filter_write != NULL);
assert(current_write_filter != NULL);
diff --git a/ui-diff.c b/ui-diff.c
index 5b6df1f..8eff178 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -311,7 +311,7 @@ static void filepair_cb(struct diff_filepair *pair)
cgit_ssdiff_footer();
 }
 
-void cgit_print_diff_ctrls()
+void cgit_print_diff_ctrls(void)
 {
int i, curr;
 
diff --git a/ui-refs.c b/ui-refs.c
index ac8a6d4..d3d71dd 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -82,7 +82,7 @@ static int print_branch(struct refinfo *ref)
return 0;
 }
 
-static void print_tag_header()
+static void print_tag_header(void)
 {
html(tr class='nohover'th class='left'Tag/th
 th class='left'Download/th
@@ -234,7 +234,7 @@ void cgit_print_tags(int maxcount)
cgit_free_reflist_inner(list);
 }
 
-void cgit_print_refs()
+void cgit_print_refs(void)
 {
 
html(table class='list nowrap');
diff --git a/ui-repolist.c b/ui-repolist.c
index e945f67..a6d0321 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -117,7 +117,7 @@ static void print_sort_header(const char *title, const char 
*sort)
htmlf('%s/a/th, title);
 }
 
-static void print_header()
+static void print_header(void)
 {
html(tr class='nohover');
print_sort_header(Name, name);
@@ -247,7 +247,7 @@ static int sort_repolist(char *field)
 }
 
 
-void cgit_print_repolist()
+void cgit_print_repolist(void)
 {
int i, columns = 3, hits = 0, header = 0;
char *last_section = NULL;
@@ -344,7 +344,7 @@ void cgit_print_repolist()
cgit_print_docend();
 }
 
-void cgit_print_site_readme()
+void cgit_print_site_readme(void)
 {
if (!ctx.cfg.root_readme)
return;
diff --git a/ui-shared.c b/ui-shared.c
index ff03cb2..6d3cfa9 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -46,7 +46,7 @@ void cgit_vprint_error(const char *fmt, va_list ap)
html(/div\n);
 }
 
-const char *cgit_httpscheme()
+const char *cgit_httpscheme(void)
 {
if (ctx.env.https  !strcmp(ctx.env.https, on))
return https://;;
@@ -54,7 +54,7 @@ const char *cgit_httpscheme()
return http://;;
 }
 
-const char *cgit_hosturl()
+const char *cgit_hosturl(void)
 {
if (ctx.env.http_host)
return ctx.env.http_host;
@@ -65,14 +65,14 @@ const char *cgit_hosturl()
return fmtalloc(%s:%s, ctx.env.server_name, ctx.env.server_port);
 }
 
-const char *cgit_currenturl()
+const char *cgit_currenturl(void)
 {
if (!ctx.qry.url)
return cgit_rooturl();
return ctx.qry.url;
 }
 
-const char *cgit_rooturl()
+const char *cgit_rooturl(void)
 {
if (ctx.cfg.virtual_root)
return ctx.cfg.virtual_root;
@@ -80,7 +80,7 @@ const char *cgit_rooturl()
return ctx.cfg.script_name;
 }
 
-const char *cgit_loginurl()
+const char *cgit_loginurl(void)
 {
static const char *login_url = 0;
if (!login_url)
@@ -735,7 +735,7 @@ void cgit_print_docstart(void)
html_include(ctx.cfg.header);
 }
 
-void cgit_print_docend()
+void cgit_print_docend(void)
 {
html(/div !-- class=content --\n);
if (ctx.cfg.embedded) {
diff --git a/ui-ssdiff.c b/ui-ssdiff.c
index 08cf513..2146c71 100644
--- a/ui-ssdiff.c
+++ b/ui-ssdiff.c
@@ -18,7 +18,7 @@ struct deferred_lines {
 static struct deferred_lines *deferred_old, *deferred_old_last;
 static struct deferred_lines *deferred_new, *deferred_new_last;
 
-static void create_or_reset_lcs_table()
+static void create_or_reset_lcs_table(void)
 {
int i;
 
@@ -276,7 +276,7 @@ static void print_ssdiff_line(char *class,
free(old_line);
 }
 
-static void print_deferred_old_lines()
+static void print_deferred_old_lines(void)
 {
struct deferred_lines *iter_old, *tmp;
iter_old = deferred_old;
@@ -289,7 +289,7 @@ static void print_deferred_old_lines()
}
 }
 
-static void 

[PATCH 00/13] Fixes for problems detected by Sparse

2015-03-08 Thread John Keeping
Sparse[0] detects several potential problems in CGit, which are all
fixed by this set of patches.  Most of these are style issues that are
correct either way (using integer zero as a NULL pointer), but I think
there is value in keeping the build clean of Sparse warnings.


[0] https://sparse.wiki.kernel.org/index.php/Main_Page

John Keeping (13):
  Makefile: add a target to run CGit through sparse
  Avoid non-ANSI function declarations
  Avoid signed bitfields
  scan-tree: make some variables 'static'
  shared: make some variables 'static'
  ui-log: make some variables 'static'
  ui-repolist: make sortcolumn definitions 'static const'
  ui-shared: make cgit_doctype 'static'
  ui-stats: make cgit_period definitions 'static const'
  ui-shared: avoid initializing static variable to zero
  ui-shared: don't use an integer as a NULL pointer
  cache: don't use an integer as a NULL pointer
  html: avoid using a plain integer as a NULL pointer

 Makefile  |  3 +++
 cache.c   |  2 +-
 cgit.c|  2 +-
 cgit.mk   |  9 -
 filter.c  |  2 +-
 html.c| 54 --
 scan-tree.c   |  4 ++--
 shared.c  |  4 ++--
 ui-blob.c |  4 ++--
 ui-diff.c |  4 ++--
 ui-log.c  |  2 +-
 ui-refs.c |  4 ++--
 ui-repolist.c | 10 +-
 ui-shared.c   | 18 +-
 ui-ssdiff.c   | 16 
 ui-stats.c| 14 +++---
 ui-stats.h|  2 +-
 ui-summary.c  |  2 +-
 ui-tree.c |  4 ++--
 19 files changed, 90 insertions(+), 70 deletions(-)

-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 01/13] Makefile: add a target to run CGit through sparse

2015-03-08 Thread John Keeping
Signed-off-by: John Keeping j...@keeping.me.uk
---
 Makefile | 3 +++
 cgit.mk  | 9 -
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index ed329e8..42ed230 100644
--- a/Makefile
+++ b/Makefile
@@ -68,6 +68,9 @@ all:: cgit
 cgit:
$(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) -f ../cgit.mk ../cgit 
$(EXTRA_GIT_TARGETS) NO_CURL=1
 
+sparse:
+   $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) -f ../cgit.mk NO_CURL=1 cgit-sparse
+
 test:
@$(MAKE) --no-print-directory cgit EXTRA_GIT_TARGETS=all
$(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all
diff --git a/cgit.mk b/cgit.mk
index 5048b09..1b50307 100644
--- a/cgit.mk
+++ b/cgit.mk
@@ -96,7 +96,7 @@ CGIT_OBJS := $(addprefix $(CGIT_PREFIX),$(CGIT_OBJ_NAMES))
 
 # Only cgit.c reference CGIT_VERSION so we only rebuild its objects when the
 # version changes.
-CGIT_VERSION_OBJS := $(addprefix $(CGIT_PREFIX),cgit.o)
+CGIT_VERSION_OBJS := $(addprefix $(CGIT_PREFIX),cgit.o cgit.sp)
 $(CGIT_VERSION_OBJS): $(CGIT_PREFIX)VERSION
 $(CGIT_VERSION_OBJS): EXTRA_CPPFLAGS = \
-DCGIT_VERSION='$(CGIT_VERSION)'
@@ -129,3 +129,10 @@ $(CGIT_OBJS): %.o: %.c GIT-CFLAGS 
$(CGIT_PREFIX)CGIT-CFLAGS $(missing_dep_dirs)
 $(CGIT_PREFIX)cgit: $(CGIT_OBJS) GIT-LDFLAGS $(GITLIBS)
@echo 11 * $(LUA_MESSAGE)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) 
$(LIBS) $(CGIT_LIBS)
+
+CGIT_SP_OBJS := $(patsubst %.o,%.sp,$(CGIT_OBJS))
+
+$(CGIT_SP_OBJS): %.sp: %.c GIT-CFLAGS $(CGIT_PREFIX)CGIT-CFLAGS FORCE
+   $(QUIET_SP)cgcc -no-compile $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) 
$(CGIT_CFLAGS) $(SPARSE_FLAGS) $
+
+cgit-sparse: $(CGIT_SP_OBJS)
-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 13/13] html: avoid using a plain integer as a NULL pointer

2015-03-08 Thread John Keeping
Sparse complains about this table because we use the integer zero as the
NULL pointer.  Use this as an opportunity to reformat the table so that
it always contains 8 elements per row, making it easier to see which
values are being set and which are not.

Signed-off-by: John Keeping j...@keeping.me.uk
---
 html.c | 54 --
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/html.c b/html.c
index f0ee2d6..155cde5 100644
--- a/html.c
+++ b/html.c
@@ -17,28 +17,38 @@
 
 /* Percent-encoding of each character, except: a-zA-Z0-9!$()*,./:;@- */
 static const char* url_escape_table[256] = {
-   %00, %01, %02, %03, %04, %05, %06, %07, %08, %09,
-   %0a, %0b, %0c, %0d, %0e, %0f, %10, %11, %12, %13,
-   %14, %15, %16, %17, %18, %19, %1a, %1b, %1c, %1d,
-   %1e, %1f, %20, 0, %22, %23, 0, %25, %26, %27, 0, 0, 0,
-   %2b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, %3c, %3d,
-   %3e, %3f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0, 0, 0, %5c, 0, %5e, 0, %60, 0, 0, 0, 0, 0,
-   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, %7b,
-   %7c, %7d, 0, %7f, %80, %81, %82, %83, %84, %85,
-   %86, %87, %88, %89, %8a, %8b, %8c, %8d, %8e, %8f,
-   %90, %91, %92, %93, %94, %95, %96, %97, %98, %99,
-   %9a, %9b, %9c, %9d, %9e, %9f, %a0, %a1, %a2, %a3,
-   %a4, %a5, %a6, %a7, %a8, %a9, %aa, %ab, %ac, %ad,
-   %ae, %af, %b0, %b1, %b2, %b3, %b4, %b5, %b6, %b7,
-   %b8, %b9, %ba, %bb, %bc, %bd, %be, %bf, %c0, %c1,
-   %c2, %c3, %c4, %c5, %c6, %c7, %c8, %c9, %ca, %cb,
-   %cc, %cd, %ce, %cf, %d0, %d1, %d2, %d3, %d4, %d5,
-   %d6, %d7, %d8, %d9, %da, %db, %dc, %dd, %de, %df,
-   %e0, %e1, %e2, %e3, %e4, %e5, %e6, %e7, %e8, %e9,
-   %ea, %eb, %ec, %ed, %ee, %ef, %f0, %f1, %f2, %f3,
-   %f4, %f5, %f6, %f7, %f8, %f9, %fa, %fb, %fc, %fd,
-   %fe, %ff
+   %00, %01, %02, %03, %04, %05, %06, %07,
+   %08, %09, %0a, %0b, %0c, %0d, %0e, %0f,
+   %10, %11, %12, %13, %14, %15, %16, %17,
+   %18, %19, %1a, %1b, %1c, %1d, %1e, %1f,
+   %20, NULL,  %22, %23, NULL,  %25, %26, %27,
+   NULL,  NULL,  NULL,  %2b, NULL,  NULL,  NULL,  NULL,
+   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
+   NULL,  NULL,  NULL,  NULL,  %3c, %3d, %3e, %3f,
+   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
+   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
+   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
+   NULL,  NULL,  NULL,  NULL,  %5c, NULL,  %5e, NULL,
+   %60, NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
+   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
+   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
+   NULL,  NULL,  NULL,  %7b, %7c, %7d, NULL,  %7f,
+   %80, %81, %82, %83, %84, %85, %86, %87,
+   %88, %89, %8a, %8b, %8c, %8d, %8e, %8f,
+   %90, %91, %92, %93, %94, %95, %96, %97,
+   %98, %99, %9a, %9b, %9c, %9d, %9e, %9f,
+   %a0, %a1, %a2, %a3, %a4, %a5, %a6, %a7,
+   %a8, %a9, %aa, %ab, %ac, %ad, %ae, %af,
+   %b0, %b1, %b2, %b3, %b4, %b5, %b6, %b7,
+   %b8, %b9, %ba, %bb, %bc, %bd, %be, %bf,
+   %c0, %c1, %c2, %c3, %c4, %c5, %c6, %c7,
+   %c8, %c9, %ca, %cb, %cc, %cd, %ce, %cf,
+   %d0, %d1, %d2, %d3, %d4, %d5, %d6, %d7,
+   %d8, %d9, %da, %db, %dc, %dd, %de, %df,
+   %e0, %e1, %e2, %e3, %e4, %e5, %e6, %e7,
+   %e8, %e9, %ea, %eb, %ec, %ed, %ee, %ef,
+   %f0, %f1, %f2, %f3, %f4, %f5, %f6, %f7,
+   %f8, %f9, %fa, %fb, %fc, %fd, %fe, %ff
 };
 
 char *fmt(const char *format, ...)
-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 08/13] ui-shared: make cgit_doctype 'static'

2015-03-08 Thread John Keeping
This is not used outside this file and is not declared.

Signed-off-by: John Keeping j...@keeping.me.uk
---
 ui-shared.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui-shared.c b/ui-shared.c
index 6d3cfa9..d4c4bb9 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -11,7 +11,7 @@
 #include cmd.h
 #include html.h
 
-const char cgit_doctype[] =
+static const char cgit_doctype[] =
 !DOCTYPE html PUBLIC \-//W3C//DTD XHTML 1.0 Transitional//EN\\n
   \http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\;\n;
 
-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 09/13] ui-stats: make cgit_period definitions 'static const'

2015-03-08 Thread John Keeping
These definitions should not be modified (and never are) so we can move
them to .rodata.

Signed-off-by: John Keeping j...@keeping.me.uk
---
 ui-stats.c | 14 +++---
 ui-stats.h |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/ui-stats.c b/ui-stats.c
index a264f6a..9cd8247 100644
--- a/ui-stats.c
+++ b/ui-stats.c
@@ -125,7 +125,7 @@ static char *pretty_year(struct tm *tm)
return fmt(%d, tm-tm_year + 1900);
 }
 
-struct cgit_period periods[] = {
+static const struct cgit_period periods[] = {
{'w', week, 12, 4, trunc_week, dec_week, inc_week, pretty_week},
{'m', month, 12, 4, trunc_month, dec_month, inc_month, pretty_month},
{'q', quarter, 12, 4, trunc_quarter, dec_quarter, inc_quarter, 
pretty_quarter},
@@ -136,7 +136,7 @@ struct cgit_period periods[] = {
  * and update the period pointer to the correcsponding struct.
  * If no matching code is found, return 0.
  */
-int cgit_find_stats_period(const char *expr, struct cgit_period **period)
+int cgit_find_stats_period(const char *expr, const struct cgit_period **period)
 {
int i;
char code = '\0';
@@ -165,7 +165,7 @@ const char *cgit_find_stats_periodname(int idx)
 }
 
 static void add_commit(struct string_list *authors, struct commit *commit,
-   struct cgit_period *period)
+   const struct cgit_period *period)
 {
struct commitinfo *info;
struct string_list_item *author, *item;
@@ -209,7 +209,7 @@ static int cmp_total_commits(const void *a1, const void *a2)
 /* Walk the commit DAG and collect number of commits per author per
  * timeperiod into a nested string_list collection.
  */
-static struct string_list collect_stats(struct cgit_period *period)
+static struct string_list collect_stats(const struct cgit_period *period)
 {
struct string_list authors;
struct rev_info rev;
@@ -256,7 +256,7 @@ static void print_combined_authorrow(struct string_list 
*authors, int from,
 const char *leftclass,
 const char *centerclass,
 const char *rightclass,
-struct cgit_period *period)
+const struct cgit_period *period)
 {
struct string_list_item *author;
struct authorstat *authorstat;
@@ -295,7 +295,7 @@ static void print_combined_authorrow(struct string_list 
*authors, int from,
 }
 
 static void print_authors(struct string_list *authors, int top,
- struct cgit_period *period)
+ const struct cgit_period *period)
 {
struct string_list_item *author;
struct authorstat *authorstat;
@@ -363,7 +363,7 @@ static void print_authors(struct string_list *authors, int 
top,
 void cgit_show_stats(void)
 {
struct string_list authors;
-   struct cgit_period *period;
+   const struct cgit_period *period;
int top, i;
const char *code = w;
 
diff --git a/ui-stats.h b/ui-stats.h
index 341ab13..0e61b03 100644
--- a/ui-stats.h
+++ b/ui-stats.h
@@ -20,7 +20,7 @@ struct cgit_period {
char *(*pretty)(struct tm *tm);
 };
 
-extern int cgit_find_stats_period(const char *expr, struct cgit_period 
**period);
+extern int cgit_find_stats_period(const char *expr, const struct cgit_period 
**period);
 extern const char *cgit_find_stats_periodname(int idx);
 
 extern void cgit_show_stats(void);
-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 10/13] ui-shared: avoid initializing static variable to zero

2015-03-08 Thread John Keeping
Sparse complains that we are using a plain integer as a NULL pointer
here, but in fact we do not have to specify a value for this variable at
all since it has static storage duration and thus will be initialized to
NULL by the compiler.

Signed-off-by: John Keeping j...@keeping.me.uk
---
 ui-shared.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui-shared.c b/ui-shared.c
index d4c4bb9..1e3c131 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -82,7 +82,7 @@ const char *cgit_rooturl(void)
 
 const char *cgit_loginurl(void)
 {
-   static const char *login_url = 0;
+   static const char *login_url;
if (!login_url)
login_url = fmtalloc(%s?p=login, cgit_rooturl());
return login_url;
-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 12/13] cache: don't use an integer as a NULL pointer

2015-03-08 Thread John Keeping
Signed-off-by: John Keeping j...@keeping.me.uk
---
 cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cache.c b/cache.c
index 900b161..cd99812 100644
--- a/cache.c
+++ b/cache.c
@@ -411,7 +411,7 @@ int cache_ls(const char *path)
DIR *dir;
struct dirent *ent;
int err = 0;
-   struct cache_slot slot = { 0 };
+   struct cache_slot slot = { NULL };
struct strbuf fullname = STRBUF_INIT;
size_t prefixlen;
 
-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 07/13] ui-repolist: make sortcolumn definitions 'static const'

2015-03-08 Thread John Keeping
These are not used outside this file and are not declared; they are also
never modified.

Signed-off-by: John Keeping j...@keeping.me.uk
---
 ui-repolist.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui-repolist.c b/ui-repolist.c
index a6d0321..2453a7f 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -223,7 +223,7 @@ struct sortcolumn {
int (*fn)(const void *a, const void *b);
 };
 
-struct sortcolumn sortcolumn[] = {
+static const struct sortcolumn sortcolumn[] = {
{section, sort_section},
{name, sort_name},
{desc, sort_desc},
@@ -234,7 +234,7 @@ struct sortcolumn sortcolumn[] = {
 
 static int sort_repolist(char *field)
 {
-   struct sortcolumn *column;
+   const struct sortcolumn *column;
 
for (column = sortcolumn[0]; column-name; column++) {
if (strcmp(field, column-name))
-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 03/13] Avoid signed bitfields

2015-03-08 Thread John Keeping
Bitfields are only defined for unsigned types.

Detected by sparse.

Signed-off-by: John Keeping j...@keeping.me.uk
---
 ui-blob.c | 4 ++--
 ui-diff.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ui-blob.c b/ui-blob.c
index a025bca..388a017 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -14,8 +14,8 @@
 struct walk_tree_context {
const char *match_path;
unsigned char *matched_sha1;
-   int found_path:1;
-   int file_only:1;
+   unsigned int found_path:1;
+   unsigned int file_only:1;
 };
 
 static int walk_tree(const unsigned char *sha1, struct strbuf *base,
diff --git a/ui-diff.c b/ui-diff.c
index 8eff178..1cf2ce0 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -31,7 +31,7 @@ static struct fileinfo {
unsigned int removed;
unsigned long old_size;
unsigned long new_size;
-   int binary:1;
+   unsigned int binary:1;
 } *items;
 
 static int use_ssdiff = 0;
-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 05/13] shared: make some variables 'static'

2015-03-08 Thread John Keeping
These are not used outside this file and are not declared.

Signed-off-by: John Keeping j...@keeping.me.uk
---
 shared.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/shared.c b/shared.c
index ae17d78..a99173b 100644
--- a/shared.c
+++ b/shared.c
@@ -284,8 +284,8 @@ static int load_mmfile(mmfile_t *file, const unsigned char 
*sha1)
  * ripped from git and modified to use globals instead of
  * a special callback-struct.
  */
-char *diffbuf = NULL;
-int buflen = 0;
+static char *diffbuf = NULL;
+static int buflen = 0;
 
 static int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf)
 {
-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[PATCH 04/13] scan-tree: make some variables 'static'

2015-03-08 Thread John Keeping
These are not used outside this file and are not declared.

Signed-off-by: John Keeping j...@keeping.me.uk
---
 scan-tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scan-tree.c b/scan-tree.c
index e900ad9..8e3cf52 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -45,8 +45,8 @@ out:
return result;
 }
 
-struct cgit_repo *repo;
-repo_config_fn config_fn;
+static struct cgit_repo *repo;
+static repo_config_fn config_fn;
 
 static void repo_config(const char *name, const char *value)
 {
-- 
2.3.1.308.g754cd77

___
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit