Skip to content

Commit

Permalink
Fixup compile on 32-bit systems
Browse files Browse the repository at this point in the history
  • Loading branch information
wez committed May 31, 2013
1 parent 8a2baf0 commit a63bc86
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 132 deletions.
5 changes: 3 additions & 2 deletions cmds/subscribe.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void cmd_unsubscribe(struct watchman_client *client, json_t *args)
sname = w_string_new(name);

pthread_mutex_lock(&w_client_lock);
deleted = w_ht_del(client->subscriptions, (w_ht_val_t)sname);
deleted = w_ht_del(client->subscriptions, w_ht_ptr_val(sname));
pthread_mutex_unlock(&w_client_lock);

w_string_delref(sname);
Expand Down Expand Up @@ -207,7 +207,8 @@ void cmd_subscribe(struct watchman_client *client, json_t *args)
}

pthread_mutex_lock(&w_client_lock);
w_ht_replace(client->subscriptions, (w_ht_val_t)sub->name, (w_ht_val_t)sub);
w_ht_replace(client->subscriptions, w_ht_ptr_val(sub->name),
w_ht_ptr_val(sub));
pthread_mutex_unlock(&w_client_lock);

resp = make_response();
Expand Down
5 changes: 3 additions & 2 deletions cmds/trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void cmd_trigger_delete(struct watchman_client *client, json_t *args)
tname = w_string_new(name);

w_root_lock(root);
res = w_ht_del(root->commands, (w_ht_val_t)tname);
res = w_ht_del(root->commands, w_ht_ptr_val(tname));
w_root_unlock(root);

w_state_save();
Expand Down Expand Up @@ -126,7 +126,8 @@ void cmd_trigger(struct watchman_client *client, json_t *args)

cmd->triggername = w_string_new(name);
w_root_lock(root);
w_ht_replace(root->commands, (w_ht_val_t)cmd->triggername, (w_ht_val_t)cmd);
w_ht_replace(root->commands, w_ht_ptr_val(cmd->triggername),
w_ht_ptr_val(cmd));
w_root_unlock(root);

w_state_save();
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ AC_INIT([watchman], [2.5], [], [watchman])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([dist-bzip2 subdir-objects])

dnl we really want you to be using 64 hardware and software
CPPFLAGS="$CPPFLAGS -D_REENTRANT"
CFLAGS="$CFLAGS -m64"
dnl we really want you to be using 64 hardware and software
dnl CFLAGS="$CFLAGS -m64"

AC_PROG_CC
AC_PROG_CPP
Expand Down
8 changes: 4 additions & 4 deletions ht.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,23 +367,23 @@ bool w_ht_iter_del(w_ht_t *ht, w_ht_iter_t *iter)

w_ht_val_t w_ht_string_copy(w_ht_val_t key)
{
w_string_addref((w_string_t*)key);
w_string_addref(w_ht_val_ptr(key));
return key;
}

void w_ht_string_del(w_ht_val_t key)
{
w_string_delref((w_string_t*)key);
w_string_delref(w_ht_val_ptr(key));
}

bool w_ht_string_equal(w_ht_val_t a, w_ht_val_t b)
{
return w_string_equal((w_string_t*)a, (w_string_t*)b);
return w_string_equal(w_ht_val_ptr(a), w_ht_val_ptr(b));
}

uint32_t w_ht_string_hash(w_ht_val_t key)
{
return ((w_string_t*)key)->hval;
return ((w_string_t*)w_ht_val_ptr(key))->hval;
}

const struct watchman_hash_funcs w_ht_string_funcs = {
Expand Down
20 changes: 9 additions & 11 deletions listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void send_error_response(struct watchman_client *client,

static void client_delete(w_ht_val_t val)
{
struct watchman_client *client = (struct watchman_client*)val;
struct watchman_client *client = w_ht_val_ptr(val);

/* cancel subscriptions */
w_ht_free(client->subscriptions);
Expand All @@ -132,9 +132,7 @@ static struct watchman_hash_funcs client_hash_funcs = {

static void delete_subscription(w_ht_val_t val)
{
struct watchman_client_subscription *sub;

sub = (struct watchman_client_subscription*)val;
struct watchman_client_subscription *sub = w_ht_val_ptr(val);

w_string_delref(sub->name);
w_query_delref(sub->query);
Expand Down Expand Up @@ -179,15 +177,15 @@ bool w_parse_clockspec(w_root_t *root,

// If we've never seen it before, ticks will be set to 0
// which is exactly what we want here.
since->ticks = (uint32_t)w_ht_get(root->cursors, (w_ht_val_t)name);
since->ticks = (uint32_t)w_ht_get(root->cursors, w_ht_ptr_val(name));

// Bump the tick value and record it against the cursor.
// We need to bump the tick value so that repeated queries
// when nothing has changed in the filesystem won't continue
// to return the same set of files; we only want the first
// of these to return the files and the rest to return nothing
// until something subsequently changes
w_ht_replace(root->cursors, (w_ht_val_t)name, ++root->ticks);
w_ht_replace(root->cursors, w_ht_ptr_val(name), ++root->ticks);

w_log(W_LOG_DBG, "resolved cursor %s -> %" PRIu32 "\n",
str, since->ticks);
Expand Down Expand Up @@ -385,8 +383,8 @@ void register_commands(struct watchman_command_handler_def *defs)
command_funcs = w_ht_new(16, &w_ht_string_funcs);
for (i = 0; defs[i].name; i++) {
w_ht_set(command_funcs,
(w_ht_val_t)w_string_new(defs[i].name),
(w_ht_val_t)defs[i].func);
w_ht_ptr_val(w_string_new(defs[i].name)),
w_ht_ptr_val(defs[i].func));
}

w_query_init_all();
Expand All @@ -411,7 +409,7 @@ bool dispatch_command(struct watchman_client *client, json_t *args)
return false;
}
cmd = w_string_new(cmd_name);
func = (watchman_command_func)w_ht_get(command_funcs, (w_ht_val_t)cmd);
func = w_ht_val_ptr(w_ht_get(command_funcs, w_ht_ptr_val(cmd)));
w_string_delref(cmd);

if (func) {
Expand Down Expand Up @@ -525,7 +523,7 @@ void w_log_to_clients(int level, const char *buf)

pthread_mutex_lock(&w_client_lock);
if (w_ht_first(clients, &iter)) do {
struct watchman_client *client = (void*)iter.value;
struct watchman_client *client = w_ht_val_ptr(iter.value);

if (client->log_level != W_LOG_OFF && client->log_level >= level) {
json = make_response();
Expand Down Expand Up @@ -762,7 +760,7 @@ bool w_start_listener(const char *path)
w_set_nonblock(client->ping[1]);

pthread_mutex_lock(&w_client_lock);
w_ht_set(clients, client->fd, (w_ht_val_t)client);
w_ht_set(clients, client->fd, w_ht_ptr_val(client));
pthread_mutex_unlock(&w_client_lock);

// Start a thread for the client.
Expand Down
2 changes: 1 addition & 1 deletion opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ bool w_getopt(struct watchman_getopt *opts, int *argcp, char ***argvp,

if (o->is_daemon) {
char *val;
asprintf(&val, "--%s=%s", o->optname, optarg);
ignore_result(asprintf(&val, "--%s=%s", o->optname, optarg));
daemon_argv[num_daemon++] = val;
}

Expand Down
17 changes: 9 additions & 8 deletions query/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ static bool suffix_generator(

for (i = 0; i < query->nsuffixes; i++) {
// Head of suffix index for this suffix
f = (void*)w_ht_get(root->suffixes, (w_ht_val_t)query->suffixes[i]);
f = w_ht_val_ptr(w_ht_get(root->suffixes,
w_ht_ptr_val(query->suffixes[i])));


// Walk and process
while (f) {
Expand Down Expand Up @@ -166,15 +168,15 @@ static bool dir_generator(
w_ht_iter_t i;

if (w_ht_first(dir->files, &i)) do {
struct watchman_file *file = (struct watchman_file*)i.value;
struct watchman_file *file = w_ht_val_ptr(i.value);

if (!w_query_process_file(query, ctx, file)) {
return false;
}
} while (w_ht_next(dir->files, &i));

if (depth > 0 && w_ht_first(dir->dirs, &i)) do {
struct watchman_dir *child = (struct watchman_dir*)i.value;
struct watchman_dir *child = w_ht_val_ptr(i.value);

if (!dir_generator(query, root, ctx, child, depth - 1)) {
return false;
Expand Down Expand Up @@ -227,7 +229,7 @@ static bool path_generator(

if (dir->files) {
file_name = w_string_basename(query->paths[i].name);
f = (struct watchman_file*)w_ht_get(dir->files, (w_ht_val_t)file_name);
f = w_ht_val_ptr(w_ht_get(dir->files, w_ht_ptr_val(file_name)));
w_string_delref(file_name);

// If it's a file (but not an existent dir)
Expand All @@ -241,8 +243,7 @@ static bool path_generator(
}

// Is it a dir?
dir = (struct watchman_dir*)w_ht_get(dir->dirs,
(w_ht_val_t)full_name);
dir = w_ht_val_ptr(w_ht_get(dir->dirs, w_ht_ptr_val(full_name)));
w_string_delref(full_name);
is_dir:
// We got a dir; process recursively to specified depth
Expand Down Expand Up @@ -317,8 +318,8 @@ bool w_query_execute(
memset(res, 0, sizeof(*res));

if (query->sync_timeout && !w_root_sync_to_now(root, query->sync_timeout)) {
asprintf(&res->errmsg, "synchronization failed: %s\n",
strerror(errno));
ignore_result(asprintf(&res->errmsg, "synchronization failed: %s\n",
strerror(errno)));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion query/fieldlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ bool parse_field_list(json_t *field_list,
}

if (!found) {
asprintf(errmsg, "unknown field name '%s'", name);
ignore_result(asprintf(errmsg, "unknown field name '%s'", name));
json_decref(field_list);
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions query/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ static w_query_expr *match_parser(w_query *query,

if (json_unpack(term, "[s,s,s]", &ignore, &pattern, &scope) != 0 &&
json_unpack(term, "[s,s]", &ignore, &pattern) != 0) {
asprintf(&query->errmsg,
ignore_result(asprintf(&query->errmsg,
"Expected [\"%s\", \"pattern\", \"scope\"?]",
which);
which));
return NULL;
}

if (strcmp(scope, "basename") && strcmp(scope, "wholename")) {
asprintf(&query->errmsg,
ignore_result(asprintf(&query->errmsg,
"Invalid scope '%s' for %s expression",
scope, which);
scope, which));
return NULL;
}

Expand Down
29 changes: 15 additions & 14 deletions query/name.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static bool eval_name(struct w_query_ctx *ctx,
}
}

matched = w_ht_lookup(name->map, (w_ht_val_t)str, &val, false);
matched = w_ht_lookup(name->map, w_ht_ptr_val(str), &val, false);

if (name->caseless) {
w_string_delref(str);
Expand Down Expand Up @@ -72,14 +72,15 @@ static w_query_expr *name_parser(w_query *query,
w_ht_t *map = NULL;

if (!json_is_array(term)) {
asprintf(&query->errmsg, "Expected array for '%s' term",
which);
ignore_result(asprintf(&query->errmsg, "Expected array for '%s' term",
which));
return NULL;
}

if (json_array_size(term) > 3) {
asprintf(&query->errmsg, "Invalid number of arguments for '%s' term",
which);
ignore_result(asprintf(&query->errmsg,
"Invalid number of arguments for '%s' term",
which));
return NULL;
}

Expand All @@ -88,18 +89,18 @@ static w_query_expr *name_parser(w_query *query,

jscope = json_array_get(term, 2);
if (!json_is_string(jscope)) {
asprintf(&query->errmsg,
ignore_result(asprintf(&query->errmsg,
"Argument 3 to '%s' must be a string",
which);
which));
return NULL;
}

scope = json_string_value(jscope);

if (strcmp(scope, "basename") && strcmp(scope, "wholename")) {
asprintf(&query->errmsg,
ignore_result(asprintf(&query->errmsg,
"Invalid scope '%s' for %s expression",
scope, which);
scope, which));
return NULL;
}
}
Expand All @@ -111,9 +112,9 @@ static w_query_expr *name_parser(w_query *query,

for (i = 0; i < json_array_size(name); i++) {
if (!json_is_string(json_array_get(name, i))) {
asprintf(&query->errmsg,
ignore_result(asprintf(&query->errmsg,
"Argument 2 to '%s' must be either a string or an array of string",
which);
which));
return NULL;
}
}
Expand All @@ -130,16 +131,16 @@ static w_query_expr *name_parser(w_query *query,
element = w_string_new(ele);
}

w_ht_set(map, (w_ht_val_t)element, 1);
w_ht_set(map, w_ht_ptr_val(element), 1);
w_string_delref(element);
}

} else if (json_is_string(name)) {
pattern = json_string_value(name);
} else {
asprintf(&query->errmsg,
ignore_result(asprintf(&query->errmsg,
"Argument 2 to '%s' must be either a string or an array of string",
which);
which));
return NULL;
}

Expand Down
12 changes: 6 additions & 6 deletions query/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bool w_query_register_expression_parser(
term_hash = w_ht_new(32, &w_ht_string_funcs);
}

return w_ht_set(term_hash, (w_ht_val_t)name, (w_ht_val_t)parser);
return w_ht_set(term_hash, w_ht_ptr_val(name), w_ht_ptr_val(parser));
}

/* parse an expression term. It can be one of:
Expand Down Expand Up @@ -47,12 +47,12 @@ w_query_expr *w_query_expr_parse(w_query *query, json_t *exp)
return NULL;
}

parser = (void*)w_ht_get(term_hash, (w_ht_val_t)name);
parser = w_ht_val_ptr(w_ht_get(term_hash, w_ht_ptr_val(name)));

if (!parser) {
asprintf(&query->errmsg,
ignore_result(asprintf(&query->errmsg,
"unknown expression term '%s'",
name->buf);
name->buf));
w_string_delref(name);
return NULL;
}
Expand Down Expand Up @@ -328,8 +328,8 @@ w_query *w_query_parse_legacy(json_t *args, char **errmsg,
const char *arg = json_string_value(json_array_get(args, i));
if (!arg) {
/* not a string value! */
asprintf(errmsg,
"rule @ position %d is not a string value", i);
ignore_result(asprintf(errmsg,
"rule @ position %d is not a string value", i));
return NULL;
}
}
Expand Down
Loading

0 comments on commit a63bc86

Please # to comment.