Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Low: const-cast char arrays where suitable
Or more frankly, where compiler complains (which is a good
approximation) + human spotted eligible parts.

Also make cast from/to "xmlChar *" explicit.
  • Loading branch information
jnpkrn committed Apr 26, 2016
commit 552e06f993dd06b5901cbf62d8feeed0f1611356
3 changes: 2 additions & 1 deletion src/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ static void free_geo_attr(gpointer data)
g_free(a);
}

int store_geo_attr(struct ticket_config *tk, const char *name, char *val, int notime)
int store_geo_attr(struct ticket_config *tk, const char *name,
const char *val, int notime)
{
struct geo_attr *a;
GDestroyNotify free_geo_attr_notify = free_geo_attr;
Expand Down
2 changes: 1 addition & 1 deletion src/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ int test_attr_reply(cmd_result_t reply_code, cmd_request_t cmd);
int do_attr_command(cmd_request_t cmd);
int process_attr_request(struct client *req_client, void *buf);
int attr_recv(void *buf, struct booth_site *source);
int store_geo_attr(struct ticket_config *tk, const char *name, char *val, int notime);
int store_geo_attr(struct ticket_config *tk, const char *name, const char *val, int notime);

#endif /* _ATTR_H */
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ static int do_attr(void)
int main(int argc, char *argv[], char *envp[])
{
int rv;
char *cp;
const char *cp;

init_set_proc_title(argc, argv, envp);
get_time(&start_time);
Expand Down
33 changes: 21 additions & 12 deletions src/pacemaker.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,27 +265,30 @@ static int pcmk_store_ticket_nonatomic(struct ticket_config *tk)
return rv;
}

typedef int (*attr_f)(struct ticket_config *tk, const char *name, char *val);
typedef int (*attr_f)(struct ticket_config *tk, const char *name,
const char *val);

struct attr_tab
{
const char *name;
attr_f handling_f;
};

static int save_expires(struct ticket_config *tk, const char *name, char *val)
static int save_expires(struct ticket_config *tk, const char *name,
const char *val)
{
secs2tv(unwall_ts(atol(val)), &tk->term_expires);
return 0;
}

static int save_term(struct ticket_config *tk, const char *name, char *val)
static int save_term(struct ticket_config *tk, const char *name,
const char *val)
{
tk->current_term = atol(val);
return 0;
}

static int parse_boolean(char *val)
static int parse_boolean(const char *val)
{
long v;

Expand All @@ -299,25 +302,29 @@ static int parse_boolean(char *val)
return v;
}

static int save_granted(struct ticket_config *tk, const char *name, char *val)
static int save_granted(struct ticket_config *tk, const char *name,
const char *val)
{
tk->is_granted = parse_boolean(val);
return 0;
}

static int save_owner(struct ticket_config *tk, const char *name, char *val)
static int save_owner(struct ticket_config *tk, const char *name,
const char *val)
{
/* No check, node could have been deconfigured. */
tk->leader = NULL;
return !find_site_by_id(atol(val), &tk->leader);
}

static int ignore_attr(struct ticket_config *tk, const char *name, char *val)
static int ignore_attr(struct ticket_config *tk, const char *name,
const char *val)
{
return 0;
}

static int save_attr(struct ticket_config *tk, const char *name, char *val)
static int save_attr(struct ticket_config *tk, const char *name,
const char *val)
{
/* tell store_geo_attr not to store time, we don't have that
* information available
Expand Down Expand Up @@ -397,13 +404,15 @@ static int save_attributes(struct ticket_config *tk, xmlDocPtr doc)
for (attr = n->properties; attr; attr = attr->next) {
v = xmlGetProp(n, attr->name);
for (atp = attr_handlers; atp->name; atp++) {
if (!strcmp(atp->name, attr->name)) {
rc = atp->handling_f(tk, attr->name, v);
if (!strcmp(atp->name, (const char *) attr->name)) {
rc = atp->handling_f(tk, (const char *) attr->name,
(const char *) v);
break;
}
}
if (!atp->name) {
rc = save_attr(tk, attr->name, v);
rc = save_attr(tk, (const char *) attr->name,
(const char *) v);
}
if (rc) {
tk_log_error("error storing attribute %s", attr->name);
Expand Down Expand Up @@ -446,7 +455,7 @@ static int parse_ticket_state(struct ticket_config *tk, FILE *p)
}
}

doc = xmlReadDoc(input->str, NULL, NULL, opts);
doc = xmlReadDoc((const xmlChar *) input->str, NULL, NULL, opts);
if (doc == NULL) {
errptr = xmlGetLastError();
if (errptr) {
Expand Down