From: "Gary V. Vaughan" <git@mlists.thewrittenword.com>
To: git@vger.kernel.org
Subject: [PATCH v5 02/18] Rewrite dynamic structure initializations to runtime assignment
Date: Fri, 14 May 2010 09:31:33 +0000 [thread overview]
Message-ID: <20100514093731.063765000@mlists.thewrittenword.com> (raw)
In-Reply-To: 20100514093131.249094000@mlists.thewrittenword.com
[-- Attachment #1: const-expr.patch --]
[-- Type: text/plain, Size: 11136 bytes --]
Unfortunately, there are still plenty of production systems with
vendor compilers that choke unless all compound declarations can be
determined statically at compile time, for example hpux10.20 (I can
provide a comprehensive list of our supported platforms that exhibit
this problem if necessary).
This patch simply breaks apart any compound declarations with dynamic
initialisation expressions, and moves the initialisation until after
the last declaration in the same block, in all the places necessary to
have the offending compilers accept the code.
Signed-off-by: Gary V. Vaughan <gary@thewrittenword.com>
---
builtin/add.c | 4 +++-
builtin/blame.c | 10 ++++++----
builtin/cat-file.c | 4 +++-
builtin/checkout.c | 3 ++-
builtin/commit.c | 3 ++-
builtin/fetch.c | 6 ++++--
builtin/remote.c | 9 ++++++---
convert.c | 4 +++-
daemon.c | 19 ++++++++++---------
ll-merge.c | 14 +++++++-------
refs.c | 6 +++++-
remote.c | 3 +--
unpack-trees.c | 4 +++-
wt-status.c | 23 ++++++++++++-----------
14 files changed, 67 insertions(+), 45 deletions(-)
Index: b/convert.c
===================================================================
--- a/convert.c
+++ b/convert.c
@@ -249,7 +249,9 @@ static int filter_buffer(int in, int out
struct child_process child_process;
struct filter_params *params = (struct filter_params *)data;
int write_err, status;
- const char *argv[] = { params->cmd, NULL };
+ const char *argv[] = { NULL, NULL };
+
+ argv[0] = params->cmd;
memset(&child_process, 0, sizeof(child_process));
child_process.argv = argv;
Index: b/remote.c
===================================================================
--- a/remote.c
+++ b/remote.c
@@ -657,10 +657,9 @@ static struct refspec *parse_refspec_int
int valid_fetch_refspec(const char *fetch_refspec_str)
{
- const char *fetch_refspec[] = { fetch_refspec_str };
struct refspec *refspec;
- refspec = parse_refspec_internal(1, fetch_refspec, 1, 1);
+ refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1);
free_refspecs(refspec, 1);
return !!refspec;
}
Index: b/unpack-trees.c
===================================================================
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -287,9 +287,11 @@ static void add_same_unmerged(struct cac
static int unpack_index_entry(struct cache_entry *ce,
struct unpack_trees_options *o)
{
- struct cache_entry *src[5] = { ce, NULL, };
+ struct cache_entry *src[5] = { NULL };
int ret;
+ src[0] = ce;
+
mark_ce_used(ce, o);
if (ce_stage(ce)) {
if (o->skip_unmerged) {
Index: b/daemon.c
===================================================================
--- a/daemon.c
+++ b/daemon.c
@@ -141,15 +141,14 @@ static char *path_ok(char *directory)
}
else if (interpolated_path && saw_extended_args) {
struct strbuf expanded_path = STRBUF_INIT;
- struct strbuf_expand_dict_entry dict[] = {
- { "H", hostname },
- { "CH", canon_hostname },
- { "IP", ip_address },
- { "P", tcp_port },
- { "D", directory },
- { NULL }
- };
+ struct strbuf_expand_dict_entry dict[6];
+ dict[0].placeholder = "H"; dict[0].value = hostname;
+ dict[1].placeholder = "CH"; dict[1].value = canon_hostname;
+ dict[2].placeholder = "IP"; dict[2].value = ip_address;
+ dict[3].placeholder = "P"; dict[3].value = tcp_port;
+ dict[4].placeholder = "D"; dict[4].value = directory;
+ dict[5].placeholder = NULL; dict[5].value = NULL;
if (*dir != '/') {
/* Allow only absolute */
logerror("'%s': Non-absolute path denied (interpolated-path active)", dir);
@@ -343,7 +342,9 @@ static int upload_pack(void)
{
/* Timeout as string */
char timeout_buf[64];
- const char *argv[] = { "upload-pack", "--strict", timeout_buf, ".", NULL };
+ const char *argv[] = { "upload-pack", "--strict", NULL, ".", NULL };
+
+ argv[2] = timeout_buf;
snprintf(timeout_buf, sizeof timeout_buf, "--timeout=%u", timeout);
return run_service_command(argv);
Index: b/wt-status.c
===================================================================
--- a/wt-status.c
+++ b/wt-status.c
@@ -498,17 +498,18 @@ static void wt_status_print_submodule_su
struct child_process sm_summary;
char summary_limit[64];
char index[PATH_MAX];
- const char *env[] = { index, NULL };
- const char *argv[] = {
- "submodule",
- "summary",
- uncommitted ? "--files" : "--cached",
- "--for-status",
- "--summary-limit",
- summary_limit,
- uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD"),
- NULL
- };
+ const char *env[] = { NULL, NULL };
+ const char *argv[8];
+
+ env[0] = index;
+ argv[0] = "submodule";
+ argv[1] = "summary";
+ argv[2] = uncommitted ? "--files" : "--cached";
+ argv[3] = "--for-status";
+ argv[4] = "--summary-limit";
+ argv[5] = summary_limit;
+ argv[6] = uncommitted ? NULL : (s->amend ? "HEAD^" : "HEAD");
+ argv[7] = NULL;
sprintf(summary_limit, "%d", s->submodule_summary);
snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
Index: b/ll-merge.c
===================================================================
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -139,17 +139,17 @@ static int ll_ext_merge(const struct ll_
{
char temp[4][50];
struct strbuf cmd = STRBUF_INIT;
- struct strbuf_expand_dict_entry dict[] = {
- { "O", temp[0] },
- { "A", temp[1] },
- { "B", temp[2] },
- { "L", temp[3] },
- { NULL }
- };
+ struct strbuf_expand_dict_entry dict[5];
const char *args[] = { NULL, NULL };
int status, fd, i;
struct stat st;
+ dict[0].placeholder = "O"; dict[0].value = temp[0];
+ dict[1].placeholder = "A"; dict[1].value = temp[1];
+ dict[2].placeholder = "B"; dict[2].value = temp[2];
+ dict[3].placeholder = "L"; dict[3].value = temp[3];
+ dict[4].placeholder = NULL; dict[4].value = NULL;
+
if (fn->cmdline == NULL)
die("custom merge driver %s lacks command line.", fn->name);
Index: b/builtin/commit.c
===================================================================
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -717,7 +717,8 @@ static int prepare_to_commit(const char
if (use_editor) {
char index[PATH_MAX];
- const char *env[2] = { index, NULL };
+ const char *env[2] = { NULL };
+ env[0] = index;
snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
if (launch_editor(git_path(commit_editmsg), NULL, env)) {
fprintf(stderr,
Index: b/builtin/remote.c
===================================================================
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -705,11 +705,14 @@ static int rm(int argc, const char **arg
struct known_remotes known_remotes = { NULL, NULL };
struct string_list branches = { NULL, 0, 0, 1 };
struct string_list skipped = { NULL, 0, 0, 1 };
- struct branches_for_remote cb_data = {
- NULL, &branches, &skipped, &known_remotes
- };
+ struct branches_for_remote cb_data;
int i, result;
+ memset(&cb_data,0,sizeof(cb_data));
+ cb_data.branches = &branches;
+ cb_data.skipped = &skipped;
+ cb_data.keep = &known_remotes;
+
if (argc != 2)
usage_with_options(builtin_remote_rm_usage, options);
Index: b/builtin/blame.c
===================================================================
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -733,10 +733,11 @@ static int pass_blame_to_parent(struct s
{
int last_in_target;
mmfile_t file_p, file_o;
- struct blame_chunk_cb_data d = { sb, target, parent, 0, 0 };
+ struct blame_chunk_cb_data d;
xpparam_t xpp;
xdemitconf_t xecfg;
-
+ memset(&d,0,sizeof(d));
+ d.sb = sb; d.target = target; d.parent=parent;
last_in_target = find_last_in_target(sb, target);
if (last_in_target < 0)
return 1; /* nothing remains for this target */
@@ -875,10 +876,11 @@ static void find_copy_in_blob(struct sco
const char *cp;
int cnt;
mmfile_t file_o;
- struct handle_split_cb_data d = { sb, ent, parent, split, 0, 0 };
+ struct handle_split_cb_data d;
xpparam_t xpp;
xdemitconf_t xecfg;
-
+ memset(&d,0,sizeof(d));
+ d.sb = sb; d.ent = ent; d.parent = parent; d.split = split;
/*
* Prepare mmfile that contains only the lines in ent.
*/
Index: b/builtin/cat-file.c
===================================================================
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -118,7 +118,9 @@ static int cat_one_file(int opt, const c
/* custom pretty-print here */
if (type == OBJ_TREE) {
- const char *ls_args[3] = {"ls-tree", obj_name, NULL};
+ const char *ls_args[3] = { NULL };
+ ls_args[0] = "ls-tree";
+ ls_args[1] = obj_name;
return cmd_ls_tree(2, ls_args, NULL);
}
Index: b/refs.c
===================================================================
--- a/refs.c
+++ b/refs.c
@@ -314,7 +314,11 @@ static int warn_if_dangling_symref(const
void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)
{
- struct warn_if_dangling_data data = { fp, refname, msg_fmt };
+ struct warn_if_dangling_data data;
+
+ data.fp = fp;
+ data.refname = refname;
+ data.msg_fmt = msg_fmt;
for_each_rawref(warn_if_dangling_symref, &data);
}
Index: b/builtin/add.c
===================================================================
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -261,12 +261,14 @@ static int edit_patch(int argc, const ch
{
char *file = xstrdup(git_path("ADD_EDIT.patch"));
const char *apply_argv[] = { "apply", "--recount", "--cached",
- file, NULL };
+ NULL, NULL };
struct child_process child;
struct rev_info rev;
int out;
struct stat st;
+ apply_argv[3] = file;
+
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
if (read_cache() < 0)
Index: b/builtin/checkout.c
===================================================================
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -609,7 +609,8 @@ static int check_tracking_name(const cha
static const char *unique_tracking_name(const char *name)
{
- struct tracking_name_data cb_data = { name, NULL, 1 };
+ struct tracking_name_data cb_data = { NULL, NULL, 1 };
+ cb_data.name = name;
for_each_ref(check_tracking_name, &cb_data);
if (cb_data.unique)
return cb_data.remote;
Index: b/builtin/fetch.c
===================================================================
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -574,9 +574,10 @@ static void find_non_local_tags(struct t
{
struct string_list existing_refs = { NULL, 0, 0, 0 };
struct string_list remote_refs = { NULL, 0, 0, 0 };
- struct tag_data data = {head, tail};
+ struct tag_data data;
const struct ref *ref;
struct string_list_item *item = NULL;
+ data.head = head; data.tail = tail;
for_each_ref(add_existing, &existing_refs);
for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
@@ -778,7 +779,8 @@ static int get_remote_group(const char *
static int add_remote_or_group(const char *name, struct string_list *list)
{
int prev_nr = list->nr;
- struct remote_group_data g = { name, list };
+ struct remote_group_data g;
+ g.name = name; g.list = list;
git_config(get_remote_group, &g);
if (list->nr == prev_nr) {
--
Gary V. Vaughan (gary@thewrittenword.com)
next prev parent reply other threads:[~2010-05-14 9:37 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-14 9:31 [PATCH v5 00/18] Portability patches for git-1.7.1 Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 01/18] Makefile: pass CPPFLAGS through to fllow customization Gary V. Vaughan
2010-05-14 9:53 ` Robin H. Johnson
2010-05-14 10:58 ` Gary V. Vaughan
2010-05-14 11:04 ` Robin H. Johnson
2010-05-14 12:01 ` Gary V. Vaughan
2010-05-14 9:31 ` Gary V. Vaughan [this message]
2010-06-02 4:39 ` [PATCH v5 02/18] Rewrite dynamic structure initializations to runtime assignment Junio C Hamano
2010-05-14 9:31 ` [PATCH v5 03/18] Makefile: -lpthread may still be necessary when libc has only pthread stubs Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 04/18] enums: omit trailing comma for portability Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 05/18] Do not use "diff" found on PATH while building and installing Gary V. Vaughan
2010-06-02 4:39 ` Junio C Hamano
2010-05-14 9:31 ` [PATCH v5 06/18] tests: use "test_cmp", not "diff", when verifying the result Gary V. Vaughan
2010-06-02 4:39 ` Junio C Hamano
2010-05-14 9:31 ` [PATCH v5 07/18] test_cmp: do not use "diff -u" on platforms that lack one Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 08/18] git-compat-util.h: some platforms with mmap() lack MAP_FAILED definition Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 09/18] Makefile: some platforms do not have hstrerror anywhere Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 10/18] Make NO_{INET_NTOP,INET_PTON} configured independently Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 11/18] Some platforms lack socklen_t type Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 12/18] Allow disabling "inline" Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 13/18] inline declaration does not work on AIX Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 14/18] Makefile: SunOS 5.6 portability fix Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 15/18] git-compat-util.h: Irix 6.5 defines sgi but not __sgi Gary V. Vaughan
2010-06-02 1:55 ` [PATCH] git-compat-util.h: use apparently more common __sgi macro to detect SGI IRIX Brandon Casey
2010-06-02 8:43 ` Gary V. Vaughan
2010-06-02 9:56 ` Tor Arntsen
2010-05-14 9:31 ` [PATCH v5 16/18] Makefile: HPUX11 portability fixes Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 17/18] Makefile: HP-UX 10.20 " Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 18/18] Makefile: Tru64 portability fix Gary V. Vaughan
2010-05-26 5:56 ` [PATCH v5 00/18] Portability patches for git-1.7.1 Gary V. Vaughan
2010-06-07 15:45 ` Gary V. Vaughan
2010-06-07 18:07 ` Junio C Hamano
2010-06-09 9:37 ` Tor Arntsen
2010-06-11 4:30 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100514093731.063765000@mlists.thewrittenword.com \
--to=git@mlists.thewrittenword.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).