Fix clang warnings and improve checks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index d5caad4..6020ec6 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -16,7 +16,7 @@ struct dl_data {
static void progress_cb(const char *str, int len, void *data)
{
- data = data;
+ (void)data;
printf("remote: %.*s", len, str);
fflush(stdout); /* We don't have the \n to force the flush */
}
@@ -50,7 +50,7 @@ exit:
static int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data)
{
char a_str[GIT_OID_HEXSZ+1], b_str[GIT_OID_HEXSZ+1];
- data = data;
+ (void)data;
git_oid_fmt(b_str, b);
b_str[GIT_OID_HEXSZ] = '\0';
@@ -76,7 +76,11 @@ int fetch(git_repository *repo, int argc, char **argv)
pthread_t worker;
#endif
- argc = argc;
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s fetch <repo>\n", argv[-1]);
+ return EXIT_FAILURE;
+ }
+
// Figure out whether it's a named remote or a URL
printf("Fetching %s for repo %p\n", argv[1], repo);
if (git_remote_load(&remote, repo, argv[1]) < 0) {
diff --git a/examples/network/index-pack.c b/examples/network/index-pack.c
index 3fc4f32..889305d 100644
--- a/examples/network/index-pack.c
+++ b/examples/network/index-pack.c
@@ -23,7 +23,7 @@
// the indexing to finish in a worker thread
static int index_cb(const git_transfer_progress *stats, void *data)
{
- data = data;
+ (void)data;
printf("\rProcessing %d of %d", stats->indexed_objects, stats->total_objects);
return 0;
@@ -39,9 +39,10 @@ int index_pack(git_repository *repo, int argc, char **argv)
ssize_t read_bytes;
char buf[512];
- repo = repo;
+ (void)repo;
+
if (argc < 2) {
- fprintf(stderr, "I need a packfile\n");
+ fprintf(stderr, "usage: %s index-pack <packfile>\n", argv[-1]);
return EXIT_FAILURE;
}
diff --git a/examples/network/ls-remote.c b/examples/network/ls-remote.c
index 737eeac..2520118 100644
--- a/examples/network/ls-remote.c
+++ b/examples/network/ls-remote.c
@@ -8,7 +8,7 @@ static int show_ref__cb(git_remote_head *head, void *payload)
{
char oid[GIT_OID_HEXSZ + 1] = {0};
- payload = payload;
+ (void)payload;
git_oid_fmt(oid, &head->oid);
printf("%s\t%s\n", oid, head->name);
return 0;
@@ -67,7 +67,11 @@ int ls_remote(git_repository *repo, int argc, char **argv)
{
int error;
- argc = argc;
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s ls-remote <remote>\n", argv[-1]);
+ return EXIT_FAILURE;
+ }
+
/* If there's a ':' in the name, assume it's an URL */
if (strchr(argv[1], ':') != NULL) {
error = use_unnamed(repo, argv[1]);
diff --git a/src/date.c b/src/date.c
index bbf88eb..ce1721a 100644
--- a/src/date.c
+++ b/src/date.c
@@ -681,8 +681,8 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm
const char *end = date;
int i;
- while (isalpha(*++end));
- ;
+ while (isalpha(*++end))
+ /* scan to non-alpha */;
for (i = 0; i < 12; i++) {
size_t match = match_string(date, month_names[i]);