Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializer
Many call sites use strbuf_init(&foo, 0) to initialize local
strbuf variable "foo" which has not been accessed since its
declaration. These can be replaced with a static initialization
using the STRBUF_INIT macro which is just as readable, saves a
function call, and takes up fewer lines.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
maint
Brandon Casey16 years agocommitted byShawn O. Pearce
@ -1820,10 +1817,9 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
@@ -1820,10 +1817,9 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
static int populate_from_stdin(struct diff_filespec *s)
{
struct strbuf buf;
struct strbuf buf = STRBUF_INIT;
size_t size = 0;
strbuf_init(&buf, 0);
if (strbuf_read(&buf, 0, 0) < 0)
return error("error while reading from stdin %s",
strerror(errno));
@ -1875,7 +1871,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
@@ -1875,7 +1871,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
if (!s->sha1_valid ||
reuse_worktree_file(s->path, s->sha1, 0)) {
struct strbuf buf;
struct strbuf buf = STRBUF_INIT;
struct stat st;
int fd;
@ -1918,7 +1914,6 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
@@ -1918,7 +1914,6 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
/*
* Convert from working tree format to canonical git format
*/
strbuf_init(&buf, 0);
if (convert_to_git(s->path, s->data, s->size, &buf, safe_crlf)) {
@ -1266,10 +1266,9 @@ static int imap_store_msg(struct store *gctx, struct msg_data *data, int *uid)
@@ -1266,10 +1266,9 @@ static int imap_store_msg(struct store *gctx, struct msg_data *data, int *uid)
static int read_message(FILE *f, struct msg_data *msg)
@ -2411,8 +2410,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
@@ -2411,8 +2410,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
size_t size = xsize_t(st->st_size);
if (!S_ISREG(st->st_mode)) {
struct strbuf sbuf;
strbuf_init(&sbuf, 0);
struct strbuf sbuf = STRBUF_INIT;
if (strbuf_read(&sbuf, fd, 4096) >= 0)
ret = index_mem(sha1, sbuf.buf, sbuf.len, write_object,