Commits

Anonymous committed 554fe20

Make some strings const

Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>

  • Participants
  • Parent commits 66eb64c

Comments (0)

Files changed (11)

File builtin-mailinfo.c

 
 static int slurp_attr(const char *line, const char *name, char *attr)
 {
-	char *ends, *ap = strcasestr(line, name);
+	const char *ends, *ap = strcasestr(line, name);
 	size_t sz;
 
 	if (!ap) {

File builtin-rev-parse.c

 		dotdot = strstr(arg, "..");
 		if (dotdot) {
 			unsigned char end[20];
-			char *next = dotdot + 2;
+			const char *next = dotdot + 2;
 			const char *this = arg;
 			*dotdot = 0;
 			if (!*next)
 		const char *hex = abbrev
 			? find_unique_abbrev(p->object.sha1, abbrev)
 			: sha1_to_hex(p->object.sha1);
-		char *dots = (abbrev && strlen(hex) != 40) ? "..." : "";
+		const char *dots = (abbrev && strlen(hex) != 40) ? "..." : "";
 		parent = parent->next;
 
 		offset += sprintf(buf + offset, " %s%s", hex, dots);
 {
 	int sockfd = -1;
 	char *colon, *end;
-	char *port = STR(DEFAULT_GIT_PORT);
+	const char *port = STR(DEFAULT_GIT_PORT);
 	struct addrinfo hints, *ai0, *ai;
 	int gai;
 
 static void git_proxy_connect(int fd[2],
 			      const char *prog, char *host, char *path)
 {
-	char *port = STR(DEFAULT_GIT_PORT);
+	const char *port = STR(DEFAULT_GIT_PORT);
 	char *colon, *end;
 	int pipefd[2][2];
 	pid_t pid;
  * after ~user/.  E.g. a request to git://host/~alice/frotz would
  * go to /home/alice/pub_git/frotz with --user-path=pub_git.
  */
-static char *user_path = NULL;
+static const char *user_path = NULL;
 
 /* Timeout, and initial timeout */
 static unsigned int timeout = 0;
 			children_reaped = reaped + 1;
 			/* XXX: Custom logging, since we don't wanna getpid() */
 			if (verbose) {
-				char *dead = "";
+				const char *dead = "";
 				if (!WIFEXITED(status) || WEXITSTATUS(status) > 0)
 					dead = " (with error)";
 				if (log_syslog)
 	return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
 }
 
-static void describe(char *arg, int last_one)
+static void describe(const char *arg, int last_one)
 {
 	unsigned char sha1[20];
 	struct commit *cmit;
 
 static void prepend_to_path(const char *dir, int len)
 {
-	char *path, *old_path = getenv("PATH");
+	const char *old_path = getenv("PATH");
+	char *path;
 	int path_len = len;
 
 	if (!old_path)
 	strlcpy(ctx->cdata, s, len + 1);
 }
 
-static struct remote_lock *lock_remote(char *path, long timeout)
+static struct remote_lock *lock_remote(const char *path, long timeout)
 {
 	struct active_request_slot *slot;
 	struct slot_results results;
 	return -1;
 }
 
-static void fetch_symref(char *path, char **symref, unsigned char *sha1)
+static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
 {
 	char *url;
 	struct buffer buffer;
 }
 
 static int
-socket_write( Socket_t *sock, char *buf, int len )
+socket_write( Socket_t *sock, const char *buf, int len )
 {
 	int n = write( sock->fd, buf, len );
 	if (n != len) {
 
 void prepare_alt_odb(void)
 {
-	char *alt;
+	const char *alt;
 
 	alt = getenv(ALTERNATE_DB_ENVIRONMENT);
 	if (!alt) alt = "";

File upload-pack.c

 		int i;
 		int args;
 		const char **argv;
+		const char **p;
 		char *buf;
-		char **p;
 
 		if (create_full_pack) {
 			args = 10;
 
 static int send_ref(const char *refname, const unsigned char *sha1)
 {
-	static char *capabilities = "multi_ack thin-pack side-band";
+	static const char *capabilities = "multi_ack thin-pack side-band";
 	struct object *o = parse_object(sha1);
 
 	if (!o)