commit - 68036464ea72a92fd21d72135814faed6abad71a
commit + 0c6f49baf2b43adf1cd027050d27fc32ef8454da
blob - ef99224d337170364b2e5458bf6e2a3206c3e05a
blob + 2b72df1a3c9e149cff31460ae7090698a3416a61
--- Makefile.inc
+++ Makefile.inc
MANDIR ?= ${PREFIX}/man/man
.else
CFLAGS += -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS += -Wunused-variable
+CFLAGS += -Wwrite-strings -Wunused-variable
PREFIX ?= ${HOME}
BINDIR ?= ${PREFIX}/bin
LIBEXECDIR ?= ${BINDIR}
blob - de5b3ba2ac5ecbd777d97ec3af715442065f7284
blob + 82a511cd01114ad856ae35699580cea0aad840cc
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
unsigned int func_id;
const char *func_name;
const struct got_error *(*func_main)(struct gw_trans *);
- char *template;
+ const char *template;
};
enum gw_query_actions {
{
struct tm tm;
time_t diff_time;
- char *years = "years ago", *months = "months ago";
- char *weeks = "weeks ago", *days = "days ago", *hours = "hours ago";
- char *minutes = "minutes ago", *seconds = "seconds ago";
- char *now = "right now";
- char *s;
+ const char *years = "years ago", *months = "months ago";
+ const char *weeks = "weeks ago", *days = "days ago", *hours = "hours ago";
+ const char *minutes = "minutes ago", *seconds = "seconds ago";
+ const char *now = "right now";
+ const char *s;
char datebuf[29];
*repo_age = NULL;
gw_colordiff_line(struct gw_trans *gw_trans, char *buf)
{
const struct got_error *error = NULL;
- char *color = NULL;
+ const char *color = NULL;
enum kcgi_err kerr = KCGI_OK;
if (strncmp(buf, "-", 1) == 0)
blob - 5dbe18b856a53a58bee722d773249a93e91993a8
blob + 4f537113e196997bfae7b568a9d90ab8fe9e77b0
--- include/got_diff.h
+++ include/got_diff.h
*/
const struct got_error *got_diff_objects_as_trees(off_t **, size_t *,
FILE *, FILE *, struct got_object_id *, struct got_object_id *,
- struct got_pathlist_head *, char *, char *, int, int, int,
+ struct got_pathlist_head *, const char *, const char *, int, int, int,
struct got_repository *, FILE *);
/*
blob - a4c18d064bd644c6fd5c1a0b49fb88bcdb340def
blob + 73d6e90e84e9a1c3190d740b2a5f86409b553e8f
--- lib/dial.c
+++ lib/dial.c
}
static int
-hassuffix(char *base, char *suf)
+hassuffix(const char *base, const char *suf)
{
int nb, ns;
const struct got_error *error = NULL;
int pid, pfd[2];
char cmd[64];
- char *argv[11];
+ const char *argv[11];
int i = 0, j;
*newpid = -1;
n = snprintf(cmd, sizeof(cmd), "git-%s-pack", direction);
if (n < 0 || n >= ssizeof(cmd))
err(1, "snprintf");
- if (execv(GOT_DIAL_PATH_SSH, argv) == -1)
+ if (execv(GOT_DIAL_PATH_SSH, (char *const *)argv) == -1)
err(1, "execv");
abort(); /* not reached */
} else {
blob - 4325a3c18009b1a5e03a0b8dae4202531c186761
blob + fea8300f838a573db96d58e41398f9efda236a06
--- lib/diff.c
+++ lib/diff.c
const struct got_error *err = NULL, *free_err;
char hex1[SHA1_DIGEST_STRING_LENGTH];
char hex2[SHA1_DIGEST_STRING_LENGTH];
- char *idstr1 = NULL, *idstr2 = NULL;
+ const char *idstr1 = NULL, *idstr2 = NULL;
off_t size1, size2;
struct got_diffreg_result *result;
off_t outoff = 0;
{
const struct got_error *err = NULL, *free_err;
char hex1[SHA1_DIGEST_STRING_LENGTH];
- char *idstr1 = NULL;
+ const char *idstr1 = NULL;
struct got_diffreg_result *result = NULL;
if (resultp)
static const struct got_error *
diff_objects_as_trees(off_t **line_offsets, size_t *nlines,
FILE *f1, FILE *f2, struct got_object_id *id1, struct got_object_id *id2,
- struct got_pathlist_head *paths,
- char *label1, char *label2, int diff_context, int ignore_whitespace,
- int force_text_diff, struct got_repository *repo, FILE *outfile)
+ struct got_pathlist_head *paths, const char *label1, const char *label2,
+ int diff_context, int ignore_whitespace, int force_text_diff,
+ struct got_repository *repo, FILE *outfile)
{
const struct got_error *err;
struct got_tree_object *tree1 = NULL, *tree2 = NULL;
const struct got_error *
got_diff_objects_as_trees(off_t **line_offsets, size_t *nlines,
FILE *f1, FILE *f2, struct got_object_id *id1, struct got_object_id *id2,
- struct got_pathlist_head *paths,
- char *label1, char *label2, int diff_context, int ignore_whitespace,
- int force_text_diff, struct got_repository *repo, FILE *outfile)
+ struct got_pathlist_head *paths, const char *label1, const char *label2,
+ int diff_context, int ignore_whitespace, int force_text_diff,
+ struct got_repository *repo, FILE *outfile)
{
const struct got_error *err;
char *idstr = NULL;
blob - 70383527274d9e8c501d2480b0479657ced378b7
blob + e44ac0a4e3f7fe9caf5b350a89c7e5c5beba00be
--- lib/diff_output.c
+++ lib/diff_output.c
struct diff_atom *start_atom, *atom;
const struct diff_data *data;
unsigned char buf[DIFF_FUNCTION_CONTEXT_SIZE];
- char *state = NULL;
+ const char *state = NULL;
int rc, i, ch;
if (result->left->atoms.len > 0 && cc->left.start > 0) {
blob - 207a6edd8617d1afeb8e3b428a73d56ebf40f146
blob + 497731a807222354a7f51153b7938cd3af00b638
--- lib/pack_create.c
+++ lib/pack_create.c
}
static const struct got_error *
-hwrite(FILE *f, void *buf, off_t len, SHA1_CTX *ctx)
+hwrite(FILE *f, const void *buf, off_t len, SHA1_CTX *ctx)
{
size_t n;
blob - eee49ec5ceec50d6d9ca6892a0641f9ae82608ff
blob + 91e2238d72a1db8caed92af293dbe6909e84d4eb
--- lib/path.c
+++ lib/path.c
got_path_find_prog(char **filename, const char *prog)
{
const struct got_error *err = NULL;
+ const char *path;
char *p;
int len;
struct stat sbuf;
- char *path, *pathcpy;
+ char *pathcpy, *dup = NULL;
*filename = NULL;
return NULL;
}
- if ((path = strdup(path)) == NULL)
+ if ((dup = strdup(path)) == NULL)
return got_error_from_errno("strdup");
- pathcpy = path;
+ pathcpy = dup;
while ((p = strsep(&pathcpy, ":")) != NULL) {
- if (*p == '\0')
- p = ".";
+ const char *d;
len = strlen(p);
while (len > 0 && p[len-1] == '/')
p[--len] = '\0'; /* strip trailing '/' */
- if (asprintf(filename, "%s/%s", p, prog) == -1) {
+ d = p;
+ if (*d == '\0')
+ d = ".";
+
+ if (asprintf(filename, "%s/%s", d, prog) == -1) {
err = got_error_from_errno("asprintf");
break;
}
*filename = NULL;
continue;
}
- free(path);
+ free(dup);
return err;
}
blob - fac056e27fdaad60303e17cfd5dcd95ca749eab2
blob + 01e0b4c5dacf2ce7ab96d2acbe62a77fc849d931
--- lib/reference.c
+++ lib/reference.c
{
const struct got_error *err;
char *packed_refs_path, *path_refs = NULL;
- char *abs_namespace = NULL;
- char *buf = NULL, *ondisk_ref_namespace = NULL;
+ char *abs_namespace = NULL, *buf = NULL;
+ const char *ondisk_ref_namespace = NULL;
char *line = NULL;
FILE *f = NULL;
struct got_reference *ref;
blob - d67081715f628dd92add8cfb5bb5cf950f5dcf87
blob + 60e2434696a95fcabec91967fcd34c362ae30aad
--- regress/fetch/fetch_test.c
+++ regress/fetch/fetch_test.c
static int quiet;
static void
-test_printf(char *fmt, ...)
+test_printf(const char *fmt, ...)
{
va_list ap;
blob - f1e809c24d6f539ddb632ad6655346337a07215d
blob + 3381d631df8b38fed1f956c7c9292b22021abddb
--- regress/path/path_test.c
+++ regress/path/path_test.c
static int quiet;
static void
-test_printf(char *fmt, ...)
+test_printf(const char *fmt, ...)
{
va_list ap;