Small source code readability improvements. Replaced magic number "0" with GIT_SUCCESS constant wherever it made sense.
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
diff --git a/src/blob.c b/src/blob.c
index c301ae1..65e1dd9 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -40,7 +40,7 @@ const char *git_blob_rawcontent(git_blob *blob)
if (blob->object.in_memory)
return NULL;
- if (!blob->object.source.open && git_object__source_open((git_object *)blob) < 0)
+ if (!blob->object.source.open && git_object__source_open((git_object *)blob) < GIT_SUCCESS)
return NULL;
return blob->object.source.raw.data;
@@ -119,13 +119,13 @@ int git_blob_writefile(git_oid *written_id, git_repository *repo, const char *pa
if (gitfo_exists(path) < 0)
return GIT_ENOTFOUND;
- if ((error = git_blob_new(&blob, repo)) < 0)
+ if ((error = git_blob_new(&blob, repo)) < GIT_SUCCESS)
return error;
- if ((error = git_blob_set_rawcontent_fromfile(blob, path)) < 0)
+ if ((error = git_blob_set_rawcontent_fromfile(blob, path)) < GIT_SUCCESS)
return error;
- if ((error = git_object_write((git_object *)blob)) < 0)
+ if ((error = git_object_write((git_object *)blob)) < GIT_SUCCESS)
return error;
git_oid_cpy(written_id, git_object_id((git_object *)blob));
diff --git a/src/commit.c b/src/commit.c
index dbb6926..7d21b88 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -114,23 +114,23 @@ int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int
clear_parents(commit);
- if ((error = git__parse_oid(&oid, &buffer, buffer_end, "tree ")) < 0)
+ if ((error = git__parse_oid(&oid, &buffer, buffer_end, "tree ")) < GIT_SUCCESS)
return error;
- if ((error = git_repository_lookup((git_object **)&commit->tree, commit->object.repo, &oid, GIT_OBJ_TREE)) < 0)
+ if ((error = git_repository_lookup((git_object **)&commit->tree, commit->object.repo, &oid, GIT_OBJ_TREE)) < GIT_SUCCESS)
return error;
/*
* TODO: commit grafts!
*/
- while (git__parse_oid(&oid, &buffer, buffer_end, "parent ") == 0) {
+ while (git__parse_oid(&oid, &buffer, buffer_end, "parent ") == GIT_SUCCESS) {
git_commit *parent;
- if ((error = git_repository_lookup((git_object **)&parent, commit->object.repo, &oid, GIT_OBJ_COMMIT)) < 0)
+ if ((error = git_repository_lookup((git_object **)&parent, commit->object.repo, &oid, GIT_OBJ_COMMIT)) < GIT_SUCCESS)
return error;
- if (git_vector_insert(&commit->parents, parent) < 0)
+ if (git_vector_insert(&commit->parents, parent) < GIT_SUCCESS)
return GIT_ENOMEM;
}
@@ -140,7 +140,7 @@ int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int
git_person__free(commit->author);
commit->author = git__malloc(sizeof(git_person));
- if ((error = git_person__parse(commit->author, &buffer, buffer_end, "author ")) < 0)
+ if ((error = git_person__parse(commit->author, &buffer, buffer_end, "author ")) < GIT_SUCCESS)
return error;
} else {
@@ -155,7 +155,7 @@ int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int
git_person__free(commit->committer);
commit->committer = git__malloc(sizeof(git_person));
- if ((error = git_person__parse(commit->committer, &buffer, buffer_end, "committer ")) < 0)
+ if ((error = git_person__parse(commit->committer, &buffer, buffer_end, "committer ")) < GIT_SUCCESS)
return error;
commit->commit_time = commit->committer->time;
@@ -199,9 +199,9 @@ int git_commit__parse_full(git_commit *commit)
int error;
if (commit->full_parse)
- return 0;
+ return GIT_SUCCESS;
- if ((error = git_object__source_open((git_object *)commit)) < 0)
+ if ((error = git_object__source_open((git_object *)commit)) < GIT_SUCCESS)
return error;
error = commit_parse_buffer(commit,
diff --git a/src/filelock.c b/src/filelock.c
index d831014..9db1cd7 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -49,7 +49,7 @@ int git_filelock_init(git_filelock *lock, const char *path)
return GIT_ERROR;
memcpy(lock->path, path, lock->path_length);
- return 0;
+ return GIT_SUCCESS;
}
int git_filelock_lock(git_filelock *lock, int append)
@@ -85,7 +85,7 @@ int git_filelock_lock(git_filelock *lock, int append)
gitfo_close(source);
}
- return 0;
+ return GIT_SUCCESS;
}
void git_filelock_unlock(git_filelock *lock)
@@ -116,7 +116,7 @@ int git_filelock_commit(git_filelock *lock)
error = gitfo_move_file(path_lock, lock->path);
- if (error < 0)
+ if (error < GIT_SUCCESS)
gitfo_unlink(path_lock);
lock->is_locked = 0;
diff --git a/src/fileops.c b/src/fileops.c
index 210e7d6..ea9935a 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -151,7 +151,7 @@ int gitfo_move_file(char *from, char *to)
int gitfo_map_ro(git_map *out, git_file fd, off_t begin, size_t len)
{
- if (git__mmap(out, len, GIT_PROT_READ, GIT_MAP_SHARED, fd, begin) < 0)
+ if (git__mmap(out, len, GIT_PROT_READ, GIT_MAP_SHARED, fd, begin) < GIT_SUCCESS)
return git_os_error();
return GIT_SUCCESS;
}
@@ -240,7 +240,7 @@ int gitfo_close_cached(gitfo_cache *ioc)
{
git_file fd;
- if (gitfo_flush_cached(ioc) < 0)
+ if (gitfo_flush_cached(ioc) < GIT_SUCCESS)
return GIT_ERROR;
fd = ioc->fd;
@@ -292,7 +292,7 @@ int gitfo_dirent(
strcpy(path + wd_len, de->d_name);
result = fn(arg, path);
- if (result < 0) {
+ if (result < GIT_SUCCESS) {
closedir(dir);
return result;
}
diff --git a/src/index.c b/src/index.c
index 488a60a..da22f70 100644
--- a/src/index.c
+++ b/src/index.c
@@ -196,14 +196,14 @@ void git_index_free(git_index *index)
int git_index_read(git_index *index)
{
struct stat indexst;
- int error = 0;
+ int error = GIT_SUCCESS;
assert(index->index_file_path);
if (!index->on_disk || gitfo_exists(index->index_file_path) < 0) {
git_index_clear(index);
index->on_disk = 0;
- return 0;
+ return GIT_SUCCESS;
}
if (gitfo_stat(index->index_file_path, &indexst) < 0)
@@ -216,13 +216,13 @@ int git_index_read(git_index *index)
gitfo_buf buffer;
- if (gitfo_read_file(&buffer, index->index_file_path) < 0)
+ if (gitfo_read_file(&buffer, index->index_file_path) < GIT_SUCCESS)
return GIT_EOSERR;
git_index_clear(index);
error = git_index__parse(index, buffer.data, buffer.len);
- if (error == 0)
+ if (error == GIT_SUCCESS)
index->last_modified = indexst.st_mtime;
gitfo_free_buf(&buffer);
@@ -239,18 +239,18 @@ int git_index_write(git_index *index)
if (!index->sorted)
git_index__sort(index);
- if (git_filelock_init(&file, index->index_file_path) < 0)
+ if (git_filelock_init(&file, index->index_file_path) < GIT_SUCCESS)
return GIT_EFLOCKFAIL;
- if (git_filelock_lock(&file, 0) < 0)
+ if (git_filelock_lock(&file, 0) < GIT_SUCCESS)
return GIT_EFLOCKFAIL;
- if (git_index__write(index, &file) < 0) {
+ if (git_index__write(index, &file) < GIT_SUCCESS) {
git_filelock_unlock(&file);
return GIT_EOSERR;
}
- if (git_filelock_commit(&file) < 0)
+ if (git_filelock_commit(&file) < GIT_SUCCESS)
return GIT_EFLOCKFAIL;
if (gitfo_stat(index->index_file_path, &indexst) == 0) {
@@ -258,7 +258,7 @@ int git_index_write(git_index *index)
index->on_disk = 1;
}
- return 0;
+ return GIT_SUCCESS;
}
unsigned int git_index_entrycount(git_index *index)
@@ -310,7 +310,7 @@ int git_index_add(git_index *index, const char *rel_path, int stage)
entry.file_size = st.st_size;
/* write the blob to disk and get the oid */
- if ((error = git_blob_writefile(&entry.oid, index->repository, full_path)) < 0)
+ if ((error = git_blob_writefile(&entry.oid, index->repository, full_path)) < GIT_SUCCESS)
return error;
entry.flags |= (stage << GIT_IDXENTRY_STAGESHIFT);
@@ -366,7 +366,7 @@ int git_index_insert(git_index *index, const git_index_entry *source_entry)
/* if no entry exists, add the entry at the end;
* the index is no longer sorted */
if (position == GIT_ENOTFOUND) {
- if (git_vector_insert(&index->entries, entry) < 0)
+ if (git_vector_insert(&index->entries, entry) < GIT_SUCCESS)
return GIT_ENOMEM;
index->sorted = 0;
@@ -480,7 +480,7 @@ static int read_tree(git_index *index, const char *buffer, size_t buffer_size)
const char *buffer_end = buffer + buffer_size;
index->tree = read_tree_internal(&buffer, buffer_end, NULL);
- return (index->tree != NULL && buffer == buffer_end) ? 0 : GIT_EOBJCORRUPTED;
+ return (index->tree != NULL && buffer == buffer_end) ? GIT_SUCCESS : GIT_EOBJCORRUPTED;
}
static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffer_size)
@@ -561,7 +561,7 @@ static int read_header(struct index_header *dest, const void *buffer)
return GIT_EOBJCORRUPTED;
dest->entry_count = ntohl(source->entry_count);
- return 0;
+ return GIT_SUCCESS;
}
static size_t read_extension(git_index *index, const char *buffer, size_t buffer_size)
@@ -585,7 +585,7 @@ static size_t read_extension(git_index *index, const char *buffer, size_t buffer
/* tree cache */
if (memcmp(dest.signature, INDEX_EXT_TREECACHE_SIG, 4) == 0) {
- if (read_tree(index, buffer + 8, dest.extension_size) < 0)
+ if (read_tree(index, buffer + 8, dest.extension_size) < GIT_SUCCESS)
return 0;
}
} else {
@@ -618,7 +618,7 @@ int git_index__parse(git_index *index, const char *buffer, size_t buffer_size)
git_hash_buf(&checksum_calculated, (const void *)buffer, buffer_size - INDEX_FOOTER_SIZE);
/* Parse header */
- if (read_header(&header, buffer) < 0)
+ if (read_header(&header, buffer) < GIT_SUCCESS)
return GIT_EOBJCORRUPTED;
seek_forward(INDEX_HEADER_SIZE);
@@ -640,7 +640,7 @@ int git_index__parse(git_index *index, const char *buffer, size_t buffer_size)
if (entry_size == 0)
return GIT_EOBJCORRUPTED;
- if (git_vector_insert(&index->entries, entry) < 0)
+ if (git_vector_insert(&index->entries, entry) < GIT_SUCCESS)
return GIT_ENOMEM;
seek_forward(entry_size);
@@ -673,14 +673,14 @@ int git_index__parse(git_index *index, const char *buffer, size_t buffer_size)
#undef seek_forward
- return 0;
+ return GIT_SUCCESS;
}
int git_index__write(git_index *index, git_filelock *file)
{
static const char NULL_BYTES[] = {0, 0, 0, 0, 0, 0, 0, 0};
- int error = 0;
+ int error = GIT_SUCCESS;
unsigned int i;
git_hash_ctx *digest;
diff --git a/src/odb.c b/src/odb.c
index fd8c271..a905f6c 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -1178,7 +1178,7 @@ static int open_pack(git_pack *p)
goto error_cleanup;
if (!git__is_sizet(p->pack_size) ||
- gitfo_map_ro(&p->pack_map, p->pack_fd, 0, (size_t)p->pack_size) < 0)
+ gitfo_map_ro(&p->pack_map, p->pack_fd, 0, (size_t)p->pack_size) < GIT_SUCCESS)
goto error_cleanup;
pack_decidx(p);
@@ -1261,25 +1261,25 @@ static int scan_one_pack(void *state, char *name)
if (git__prefixcmp(s + 1, "pack-")
|| git__suffixcmp(s, ".pack")
|| strlen(s + 1) != GIT_PACK_NAME_MAX + 4)
- return 0;
+ return GIT_SUCCESS;
d = strrchr(s + 1, '.');
strcpy(d + 1, "idx"); /* "pack-abc.pack" -> "pack-abc.idx" */
if (gitfo_exists(name))
- return 0;
+ return GIT_SUCCESS;
if ((r = git__malloc(sizeof(*r))) == NULL)
- return GIT_ERROR;
+ return GIT_ERROR; /* GIT_ENOMEM? */
*d = '\0'; /* "pack-abc.pack" -_> "pack-abc" */
if ((r->pack = alloc_pack(s + 1)) == NULL) {
free(r);
- return GIT_ERROR;
+ return GIT_ERROR; /* GIT_ENOMEM? */
}
r->next = *ret;
*ret = r;
- return 0;
+ return GIT_SUCCESS;
}
static git_packlist *scan_packs(git_odb *db)
@@ -1559,7 +1559,7 @@ static int open_alternates(git_odb *db)
db->alternates[n] = NULL;
db->n_alternates = n;
gitlck_unlock(&db->lock);
- return 0;
+ return GIT_SUCCESS;
}
@@ -1614,8 +1614,8 @@ static int read_header_packed(git_rawobj *out, const obj_location *loc)
if (pack_openidx(pack))
return GIT_EPACKCORRUPTED;
- if (pack->idx_get(&e, pack, loc->pack.n) < 0 ||
- open_pack(pack) < 0) {
+ if (pack->idx_get(&e, pack, loc->pack.n) < GIT_SUCCESS ||
+ open_pack(pack) < GIT_SUCCESS) {
error = GIT_ENOTFOUND;
goto cleanup;
}
@@ -1662,7 +1662,7 @@ static int read_loose(git_rawobj *out, git_odb *db, const obj_location *loc)
out->len = 0;
out->type = GIT_OBJ_BAD;
- if (gitfo_read_file(&obj, loc->loose_path) < 0)
+ if (gitfo_read_file(&obj, loc->loose_path) < GIT_SUCCESS)
return GIT_ENOTFOUND;
error = inflate_disk_obj(out, &obj);
@@ -1725,10 +1725,10 @@ static int write_obj(gitfo_buf *buf, git_oid *id, git_odb *db)
if (object_file_name(file, sizeof(file), db->objects_dir, id))
return GIT_EOSERR;
- if (make_temp_file(&fd, temp, sizeof(temp), file) < 0)
+ if (make_temp_file(&fd, temp, sizeof(temp), file) < GIT_SUCCESS)
return GIT_EOSERR;
- if (gitfo_write(fd, buf->data, buf->len) < 0) {
+ if (gitfo_write(fd, buf->data, buf->len) < GIT_SUCCESS) {
gitfo_close(fd);
gitfo_unlink(temp);
return GIT_EOSERR;
@@ -1739,7 +1739,7 @@ static int write_obj(gitfo_buf *buf, git_oid *id, git_odb *db)
gitfo_close(fd);
gitfo_chmod(temp, 0444);
- if (gitfo_move_file(temp, file) < 0) {
+ if (gitfo_move_file(temp, file) < GIT_SUCCESS) {
gitfo_unlink(temp);
return GIT_EOSERR;
}
@@ -1839,7 +1839,7 @@ int git_odb_exists(git_odb *db, const git_oid *id)
int git_odb_read_header(git_rawobj *out, git_odb *db, const git_oid *id)
{
obj_location loc;
- int found, error = 0;
+ int found, error = GIT_SUCCESS;
assert(out && db);
@@ -1868,7 +1868,7 @@ int git_odb_read(
const git_oid *id)
{
obj_location loc;
- int found, error = 0;
+ int found, error = GIT_SUCCESS;
assert(out && db);
@@ -1900,16 +1900,16 @@ int git_odb_write(git_oid *id, git_odb *db, git_rawobj *obj)
assert(id && db && obj);
- if ((error = hash_obj(id, hdr, sizeof(hdr), &hdrlen, obj)) < 0)
+ if ((error = hash_obj(id, hdr, sizeof(hdr), &hdrlen, obj)) < GIT_SUCCESS)
return error;
if (git_odb_exists(db, id))
return GIT_SUCCESS;
- if ((error = deflate_obj(&buf, hdr, hdrlen, obj, db->object_zlib_level)) < 0)
+ if ((error = deflate_obj(&buf, hdr, hdrlen, obj, db->object_zlib_level)) < GIT_SUCCESS)
return error;
- if ((error = write_obj(&buf, id, db)) < 0) {
+ if ((error = write_obj(&buf, id, db)) < GIT_SUCCESS) {
gitfo_free_buf(&buf);
return error;
}
diff --git a/src/oid.c b/src/oid.c
index a14c935..f86098d 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -134,12 +134,12 @@ int git__parse_oid(git_oid *oid, char **buffer_out,
if (buffer[header_len + sha_len] != '\n')
return GIT_EOBJCORRUPTED;
- if (git_oid_mkstr(oid, buffer + header_len) < 0)
+ if (git_oid_mkstr(oid, buffer + header_len) < GIT_SUCCESS)
return GIT_EOBJCORRUPTED;
*buffer_out = buffer + (header_len + sha_len + 1);
- return 0;
+ return GIT_SUCCESS;
}
int git__write_oid(git_odb_source *src, const char *header, const git_oid *oid)
diff --git a/src/person.c b/src/person.c
index 0ab6a2d..9410913 100644
--- a/src/person.c
+++ b/src/person.c
@@ -129,7 +129,7 @@ int git_person__parse(git_person *person, char **buffer_out,
return GIT_EOBJCORRUPTED;
*buffer_out = (line_end + 1);
- return 0;
+ return GIT_SUCCESS;
}
int git_person__write(git_odb_source *src, const char *header, const git_person *person)
diff --git a/src/repository.c b/src/repository.c
index c915ddd..eade02c 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -84,7 +84,7 @@ static int assign_repository_folders(git_repository *repo,
assert(repo);
- if (git_dir == NULL || gitfo_isdir(git_dir) < 0)
+ if (git_dir == NULL || gitfo_isdir(git_dir) < GIT_SUCCESS)
return GIT_ENOTFOUND;
@@ -107,7 +107,7 @@ static int assign_repository_folders(git_repository *repo,
else
strcpy(path_aux, git_object_directory);
- if (gitfo_isdir(path_aux) < 0)
+ if (gitfo_isdir(path_aux) < GIT_SUCCESS)
return GIT_ENOTFOUND;
repo->path_odb = git__strdup(path_aux);
@@ -139,7 +139,7 @@ static int guess_repository_folders(git_repository *repo, const char *repository
char path_aux[GIT_PATH_MAX], *last_folder;
int path_len;
- if (gitfo_isdir(repository_path) < 0)
+ if (gitfo_isdir(repository_path) < GIT_SUCCESS)
return GIT_ENOTAREPO;
path_len = strlen(repository_path);
@@ -156,7 +156,7 @@ static int guess_repository_folders(git_repository *repo, const char *repository
/* objects database */
strcpy(path_aux + path_len, GIT_OBJECTS_FOLDER);
- if (gitfo_isdir(path_aux) < 0)
+ if (gitfo_isdir(path_aux) < GIT_SUCCESS)
return GIT_ENOTAREPO;
repo->path_odb = git__strdup(path_aux);
@@ -233,11 +233,11 @@ int git_repository_open2(git_repository **repo_out,
git_index_file,
git_work_tree);
- if (error < 0)
+ if (error < GIT_SUCCESS)
goto cleanup;
error = git_odb_open(&repo->db, repo->path_odb);
- if (error < 0)
+ if (error < GIT_SUCCESS)
goto cleanup;
*repo_out = repo;
@@ -260,11 +260,11 @@ int git_repository_open(git_repository **repo_out, const char *path)
return GIT_ENOMEM;
error = guess_repository_folders(repo, path);
- if (error < 0)
+ if (error < GIT_SUCCESS)
goto cleanup;
error = git_odb_open(&repo->db, repo->path_odb);
- if (error < 0)
+ if (error < GIT_SUCCESS)
goto cleanup;
*repo_out = repo;
@@ -302,7 +302,7 @@ void git_repository_free(git_repository *repo)
git_index *git_repository_index(git_repository *repo)
{
if (repo->index == NULL) {
- if (git_index_open_inrepo(&repo->index, repo) < 0)
+ if (git_index_open_inrepo(&repo->index, repo) < GIT_SUCCESS)
return NULL;
assert(repo->index);
@@ -344,7 +344,7 @@ int git__source_printf(git_odb_source *source, const char *format, ...)
len = vsnprintf(source->write_ptr, source->raw.len - source->written_bytes, format, arglist);
while (source->written_bytes + len >= source->raw.len) {
- if (source_resize(source) < 0)
+ if (source_resize(source) < GIT_SUCCESS)
return GIT_ENOMEM;
did_resize = 1;
@@ -366,7 +366,7 @@ int git__source_write(git_odb_source *source, const void *bytes, size_t len)
assert(source->open && source->write_ptr);
while (source->written_bytes + len >= source->raw.len) {
- if (source_resize(source) < 0)
+ if (source_resize(source) < GIT_SUCCESS)
return GIT_ENOMEM;
}
@@ -404,7 +404,7 @@ static int write_back(git_object *object)
object->source.raw.len = object->source.written_bytes;
- if ((error = git_odb_write(&new_id, object->repo->db, &object->source.raw)) < 0)
+ if ((error = git_odb_write(&new_id, object->repo->db, &object->source.raw)) < GIT_SUCCESS)
return error;
if (!object->in_memory)
@@ -433,7 +433,7 @@ int git_object__source_open(git_object *object)
git_object__source_close(object);
error = git_odb_read(&object->source.raw, object->repo->db, &object->id);
- if (error < 0)
+ if (error < GIT_SUCCESS)
return error;
object->source.open = 1;
@@ -485,7 +485,7 @@ int git_object_write(git_object *object)
break;
}
- if (error < 0) {
+ if (error < GIT_SUCCESS) {
git_object__source_close(object);
return error;
}
@@ -590,7 +590,7 @@ int git_repository_lookup(git_object **object_out, git_repository *repo, const g
{
git_object *object = NULL;
git_rawobj obj_file;
- int error = 0;
+ int error = GIT_SUCCESS;
assert(repo && object_out && id);
@@ -601,7 +601,7 @@ int git_repository_lookup(git_object **object_out, git_repository *repo, const g
}
error = git_odb_read(&obj_file, repo->db, id);
- if (error < 0)
+ if (error < GIT_SUCCESS)
return error;
if (type != GIT_OBJ_ANY && type != obj_file.type)
@@ -644,7 +644,7 @@ int git_repository_lookup(git_object **object_out, git_repository *repo, const g
break;
}
- if (error < 0) {
+ if (error < GIT_SUCCESS) {
git_object_free(object);
return error;
}
diff --git a/src/tag.c b/src/tag.c
index f612cf3..920a72b 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -206,7 +206,7 @@ static int parse_tag_buffer(git_tag *tag, char *buffer, const char *buffer_end)
memcpy(tag->message, buffer, text_len);
tag->message[text_len] = '\0';
- return 0;
+ return GIT_SUCCESS;
}
int git_tag__writeback(git_tag *tag, git_odb_source *src)
diff --git a/src/tree.c b/src/tree.c
index 2eeba72..a0138ca 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -238,12 +238,12 @@ static int tree_parse_buffer(git_tree *tree, char *buffer, char *buffer_end)
{
static const size_t avg_entry_size = 40;
unsigned int expected_size;
- int error = 0;
+ int error = GIT_SUCCESS;
expected_size = (tree->object.source.raw.len / avg_entry_size) + 1;
free_tree_entries(tree);
- if (git_vector_init(&tree->entries, expected_size, entry_sort_cmp, entry_search_cmp) < 0)
+ if (git_vector_init(&tree->entries, expected_size, entry_sort_cmp, entry_search_cmp) < GIT_SUCCESS)
return GIT_ENOMEM;
while (buffer < buffer_end) {
@@ -255,7 +255,7 @@ static int tree_parse_buffer(git_tree *tree, char *buffer, char *buffer_end)
break;
}
- if (git_vector_insert(&tree->entries, entry) < 0)
+ if (git_vector_insert(&tree->entries, entry) < GIT_SUCCESS)
return GIT_ENOMEM;
entry->owner = tree;