List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH 1/2] ui-shared: fix decl-after-statement warnings
@ 2016-08-07 15:15 john
  2016-08-07 15:15 ` [PATCH 2/2] ui-ssdiff: " john
  0 siblings, 1 reply; 2+ messages in thread
From: john @ 2016-08-07 15:15 UTC (permalink / raw)


git.git's coding style avoids decl-after-statement and we generally try
to follow it but a few warnings have crept in recently.  Fix the ones in
ui-shared.c

Signed-off-by: John Keeping <john at keeping.me.uk>
---
 ui-shared.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/ui-shared.c b/ui-shared.c
index e39d004..3fa36d6 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -66,10 +66,11 @@ char *cgit_hosturl(void)
 
 char *cgit_currenturl(void)
 {
-	if (!ctx.qry.url)
-		return xstrdup(cgit_rooturl());
 	const char *root = cgit_rooturl();
 	size_t len = strlen(root);
+
+	if (!ctx.qry.url)
+		return xstrdup(root);
 	if (len && root[len - 1] == '/')
 		return fmtalloc("%s%s", root, ctx.qry.url);
 	return fmtalloc("%s/%s", root, ctx.qry.url);
@@ -349,6 +350,8 @@ void cgit_log_link(const char *name, const char *title, const char *class,
 void cgit_commit_link(char *name, const char *title, const char *class,
 		      const char *head, const char *rev, const char *path)
 {
+	char *delim;
+
 	if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
 		name[ctx.cfg.max_msg_len] = '\0';
 		name[ctx.cfg.max_msg_len - 1] = '.';
@@ -356,8 +359,6 @@ void cgit_commit_link(char *name, const char *title, const char *class,
 		name[ctx.cfg.max_msg_len - 3] = '.';
 	}
 
-	char *delim;
-
 	delim = repolink(title, class, "commit", head, path);
 	if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
 		html(delim);
@@ -714,13 +715,14 @@ static void print_rel_vcs_link(const char *url)
 
 void cgit_print_docstart(void)
 {
+	char *host = cgit_hosturl();
+
 	if (ctx.cfg.embedded) {
 		if (ctx.cfg.header)
 			html_include(ctx.cfg.header);
 		return;
 	}
 
-	char *host = cgit_hosturl();
 	html(cgit_doctype);
 	html("<html lang='en'>\n");
 	html("<head>\n");
-- 
2.9.2.639.g855ae9f



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] ui-ssdiff: fix decl-after-statement warnings
  2016-08-07 15:15 [PATCH 1/2] ui-shared: fix decl-after-statement warnings john
@ 2016-08-07 15:15 ` john
  0 siblings, 0 replies; 2+ messages in thread
From: john @ 2016-08-07 15:15 UTC (permalink / raw)


git.git's coding style avoids decl-after-statement and we generally try
to follow it but a few warnings have crept in recently.  Fix the one in
ui-ssdiff.c

Signed-off-by: John Keeping <john at keeping.me.uk>
---
 ui-ssdiff.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui-ssdiff.c b/ui-ssdiff.c
index d183d40..84e482b 100644
--- a/ui-ssdiff.c
+++ b/ui-ssdiff.c
@@ -92,7 +92,7 @@ static char *longest_common_subsequence(char *A, char *B)
 static int line_from_hunk(char *line, char type)
 {
 	char *buf1, *buf2;
-	int len;
+	int len, res;
 
 	buf1 = strchr(line, type);
 	if (buf1 == NULL)
@@ -105,7 +105,7 @@ static int line_from_hunk(char *line, char type)
 	buf2 = xmalloc(len + 1);
 	strncpy(buf2, buf1, len);
 	buf2[len] = '\0';
-	int res = atoi(buf2);
+	res = atoi(buf2);
 	free(buf2);
 	return res;
 }
-- 
2.9.2.639.g855ae9f



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-07 15:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-07 15:15 [PATCH 1/2] ui-shared: fix decl-after-statement warnings john
2016-08-07 15:15 ` [PATCH 2/2] ui-ssdiff: " john

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).