Skip to content

Commit e74435a

Browse files
peffgitster
authored andcommitted
sha1write: make buffer const-correct
We are passed a "void *" and write it out without ever touching it; let's indicate that by using "const". Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3d092bf commit e74435a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

csum-file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "progress.h"
1212
#include "csum-file.h"
1313

14-
static void flush(struct sha1file *f, void *buf, unsigned int count)
14+
static void flush(struct sha1file *f, const void *buf, unsigned int count)
1515
{
1616
if (0 <= f->check_fd && count) {
1717
unsigned char check_buffer[8192];
@@ -86,13 +86,13 @@ int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
8686
return fd;
8787
}
8888

89-
int sha1write(struct sha1file *f, void *buf, unsigned int count)
89+
int sha1write(struct sha1file *f, const void *buf, unsigned int count)
9090
{
9191
while (count) {
9292
unsigned offset = f->offset;
9393
unsigned left = sizeof(f->buffer) - offset;
9494
unsigned nr = count > left ? left : count;
95-
void *data;
95+
const void *data;
9696

9797
if (f->do_crc)
9898
f->crc32 = crc32(f->crc32, buf, nr);

csum-file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern struct sha1file *sha1fd(int fd, const char *name);
3434
extern struct sha1file *sha1fd_check(const char *name);
3535
extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
3636
extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
37-
extern int sha1write(struct sha1file *, void *, unsigned int);
37+
extern int sha1write(struct sha1file *, const void *, unsigned int);
3838
extern void sha1flush(struct sha1file *f);
3939
extern void crc32_begin(struct sha1file *);
4040
extern uint32_t crc32_end(struct sha1file *);

0 commit comments

Comments
 (0)