git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v6 5/7] pack-bitmap.c: using error() instead of silently returning -1

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 11, 2022, 14:53 UTC
Message-ID
<220711.86bktv7l5v.gmgdl@evledraar.gmail.com>
In-Reply-To
<52783555e206060465743b5587580a6bd4a1f008.1657540174.git.dyroneteng@gmail.com>
On Mon, Jul 11 2022, Teng Long wrote:
Good to report errno now, however...
Show 15 quoted lines
> Signed-off-by: Teng Long <dyroneteng@gmail.com>
> ---
>  pack-bitmap.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/pack-bitmap.c b/pack-bitmap.c
> index 319eb721d8..fbe3f58aff 100644
> --- a/pack-bitmap.c
> +++ b/pack-bitmap.c
> @@ -327,7 +327,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
>  
>  	if (fstat(fd, &st)) {
>  		close(fd);
> -		return -1;
> +		return error_errno(_("cannot fstat bitmap file"));

This is a logic error, as fstat() failed, but you're reproting errno() after our call to close(), at which point it's anyone's guess what "errno" is. It's only meaningful immediately after a system call.

So either:
    error_errno(....);
    close(fd);
    return -1;
Or even better:
    error_errno(...)
    if (close(fd))
        warning_errno("cannot close() bitmap file");
    return -1;
Although that last one may be too pedantic.
Show 21 quoted lines
>  	}
>  
>  	if (bitmap_git->pack || bitmap_git->midx) {
> @@ -350,8 +350,10 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
>  	if (load_bitmap_header(bitmap_git) < 0)
>  		goto cleanup;
>  
> -	if (!hasheq(get_midx_checksum(bitmap_git->midx), bitmap_git->checksum))
> +	if (!hasheq(get_midx_checksum(bitmap_git->midx), bitmap_git->checksum)) {
> +		error(_("checksum doesn't match in MIDX and bitmap"));
>  		goto cleanup;
> +	}
>  
>  	if (load_midx_revindex(bitmap_git->midx) < 0) {
>  		warning(_("multi-pack bitmap is missing required reverse index"));
> @@ -390,7 +392,7 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
>  
>  	if (fstat(fd, &st)) {
>  		close(fd);
> -		return -1;
> +		return error_errno(_("cannot fstat bitmap file"));
Same issue here.
Previous: Teng LongNext: Teng Long
Message 95 of 128 in “trace2 output for bitmap decision path”
  1. 0/3 trace2 output for bitmap decision pathTeng Long, Mar 24, 2022
  2. 1/3 pack-bitmap.c: use "ret" in "open_midx_bitmap()"Teng Long, Mar 24, 2022
  3. Taylor BlauMar 24, 2022
  4. Teng LongMar 28, 2022
  5. Taylor BlauMar 30, 2022
  6. 2/3 pack-bitmap.c: add "break" statement in "open_pack_bitmap()"Teng Long, Mar 24, 2022
  7. Junio C HamanoMar 24, 2022
  8. Taylor BlauMar 24, 2022
  9. Taylor BlauMar 24, 2022
  10. Teng LongMar 29, 2022
  11. Taylor BlauMar 30, 2022
  12. Teng LongTeng Long, Mar 30, 2022
  13. Ævar Arnfjörð BjarmasonMar 30, 2022
  14. 3/3 bitmap: add trace outputs during open "bitmap" fileTeng Long, Mar 24, 2022
  15. Junio C HamanoMar 24, 2022
  16. Ævar Arnfjörð BjarmasonMar 24, 2022
  17. Teng LongTeng Long, Mar 29, 2022
  18. Ævar Arnfjörð BjarmasonMar 29, 2022
  19. 0/5 trace2 output for bitmap decision pathTeng Long, Apr 21, 2022
  20. 1/5 pack-bitmap.c: continue looping when first MIDX bitmap is foundTeng Long, Apr 21, 2022
  21. Taylor BlauMay 11, 2022
  22. 2/5 pack-bitmap.c: rename "idx_name" to "bitmap_name"Teng Long, Apr 21, 2022
  23. Taylor BlauMay 11, 2022
  24. 3/5 pack-bitmap.c: make warnings more detailed when opening bitmapTeng Long, Apr 21, 2022
  25. Taylor BlauApr 21, 2022
  26. Teng LongMay 6, 2022
  27. 5/5 pack-bitmap.c: using error() instead of silently returning -1Teng Long, Apr 21, 2022
  28. Ævar Arnfjörð BjarmasonApr 21, 2022
  29. Teng LongMay 6, 2022
  30. 4/5 bitmap: add trace2 outputs during open "bitmap" fileTeng Long, Apr 21, 2022
  31. Ævar Arnfjörð BjarmasonApr 21, 2022
  32. Teng LongMay 6, 2022
  33. Teng LongMay 6, 2022
  34. Jeff HostetlerApr 21, 2022
  35. Teng LongMay 6, 2022
  36. Jeff HostetlerMay 10, 2022
  37. 0/5 trace2 output for bitmap decision pathTeng Long, Jun 12, 2022
  38. 1/5 pack-bitmap.c: continue looping when first MIDX bitmap is foundTeng Long, Jun 12, 2022
  39. 3/5 pack-bitmap.c: make warnings support i18N when opening bitmapTeng Long, Jun 12, 2022
  40. 2/5 pack-bitmap.c: rename "idx_name" to "bitmap_name"Teng Long, Jun 12, 2022
  41. 4/5 pack-bitmap.c: using error() instead of silently returning -1Teng Long, Jun 12, 2022
  42. Taylor BlauJun 14, 2022
  43. Teng LongJun 20, 2022
  44. 5/5 bitmap: add trace2 outputs during open "bitmap" fileTeng Long, Jun 12, 2022
  45. Junio C HamanoJun 13, 2022
  46. Teng LongJun 20, 2022
  47. Taylor BlauJun 14, 2022
  48. Teng LongJun 21, 2022
  49. Jeff HostetlerJun 22, 2022
  50. Teng LongJun 23, 2022
  51. Jeff HostetlerJun 23, 2022
  52. Teng LongJun 24, 2022
  53. 0/5 trace2 output for bitmap decision pathTeng Long, Jun 21, 2022
  54. 1/5 pack-bitmap.c: continue looping when first MIDX bitmap is foundTeng Long, Jun 21, 2022
  55. 3/5 pack-bitmap.c: make warnings support i18N when opening bitmapTeng Long, Jun 21, 2022
  56. 2/5 pack-bitmap.c: rename "idx_name" to "bitmap_name"Teng Long, Jun 21, 2022
  57. 5/5 bitmap: add trace2 outputs during open "bitmap" fileTeng Long, Jun 21, 2022
  58. Jeff HostetlerJun 22, 2022
  59. Junio C HamanoJun 22, 2022
  60. 4/5 pack-bitmap.c: using error() instead of silently returning -1Teng Long, Jun 21, 2022
  61. 0/5 tr2: avoid to print "interesting" config repeatedlyTeng Long, Jun 28, 2022
  62. 1/5 pack-bitmap.c: continue looping when first MIDX bitmap is foundTeng Long, Jun 28, 2022
  63. 2/5 pack-bitmap.c: rename "idx_name" to "bitmap_name"Teng Long, Jun 28, 2022
  64. 3/5 pack-bitmap.c: using error() instead of silently returning -1Teng Long, Jun 28, 2022
  65. Junio C HamanoJun 28, 2022
  66. Teng LongJul 5, 2022
  67. Junio C HamanoJul 5, 2022
  68. 4/5 pack-bitmap.c: retrieve missing i18n translationsTeng Long, Jun 28, 2022
  69. Ævar Arnfjörð BjarmasonJun 28, 2022
  70. Eric SunshineJun 28, 2022
  71. Teng LongJul 6, 2022
  72. Teng LongJul 6, 2022
  73. Junio C HamanoJun 28, 2022
  74. Teng LongJul 7, 2022
  75. Junio C HamanoJul 7, 2022
  76. Teng LongJul 11, 2022
  77. 5/5 tr2: avoid to print "interesting" config repeatedlyTeng Long, Jun 28, 2022
  78. Ævar Arnfjörð BjarmasonJun 28, 2022
  79. Junio C HamanoJun 28, 2022
  80. Jeff HostetlerJul 1, 2022
  81. Teng LongJul 11, 2022
  82. Teng LongJul 11, 2022
  83. 0/7 trace2: dump scope when print "interesting" configTeng Long, Jul 11, 2022
  84. 1/7 clean: fixed issues related to text output formatTeng Long, Jul 11, 2022
  85. Junio C HamanoJul 11, 2022
  86. Teng LongJul 13, 2022
  87. 2/7 pack-bitmap.c: mark more strings for translationsTeng Long, Jul 11, 2022
  88. 3/7 pack-bitmap.c: rename "idx_name" to "bitmap_name"Teng Long, Jul 11, 2022
  89. 4/7 pack-bitmap.c: don't ignore ENOENT silentlyTeng Long, Jul 11, 2022
  90. Ævar Arnfjörð BjarmasonJul 11, 2022
  91. Teng LongJul 13, 2022
  92. Junio C HamanoJul 11, 2022
  93. Teng LongJul 14, 2022
  94. 5/7 pack-bitmap.c: using error() instead of silently returning -1Teng Long, Jul 11, 2022
  95. Ævar Arnfjörð BjarmasonJul 11, 2022
  96. Teng LongJul 15, 2022
  97. 6/7 pack-bitmap.c: continue looping when first MIDX bitmap is foundTeng Long, Jul 11, 2022
  98. 7/7 tr2: dump names if config exist in multiple scopesTeng Long, Jul 11, 2022
  99. Ævar Arnfjörð BjarmasonJul 11, 2022
  100. Jeff HostetlerJul 11, 2022
  101. Ævar Arnfjörð BjarmasonJul 11, 2022
  102. Teng LongJul 18, 2022
  103. 0/7 trace2: dump scope when print "interesting" configTeng Long, Jul 18, 2022
  104. 1/7 pack-bitmap.c: fix formatting of error messagesTeng Long, Jul 18, 2022
  105. 2/7 pack-bitmap.c: mark more strings for translationsTeng Long, Jul 18, 2022
  106. 3/7 pack-bitmap.c: rename "idx_name" to "bitmap_name"Teng Long, Jul 18, 2022
  107. 4/7 pack-bitmap.c: do not ignore error when opening a bitmap fileTeng Long, Jul 18, 2022
  108. 5/7 pack-bitmap.c: using error() instead of silently returning -1Teng Long, Jul 18, 2022
  109. 6/7 pack-bitmap.c: continue looping when first MIDX bitmap is foundTeng Long, Jul 18, 2022
  110. 7/7 tr2: dump names if config exist in multiple scopesTeng Long, Jul 18, 2022
  111. Jeff HostetlerJul 18, 2022
  112. tenglong.tlJul 19, 2022
  113. Junio C HamanoJul 19, 2022
  114. tenglong.tlJul 20, 2022
  115. Junio C HamanoJul 18, 2022
  116. Ævar Arnfjörð BjarmasonJul 18, 2022
  117. tenglong.tlJul 19, 2022
  118. Ævar Arnfjörð BjarmasonJul 19, 2022
  119. tenglong.tlJul 19, 2022
  120. 0/6 pack-bitmap.c: optimize error messagestenglong.tl, Jul 21, 2022
  121. 1/6 pack-bitmap.c: fix formatting of error messagestenglong.tl, Jul 21, 2022
  122. 2/6 pack-bitmap.c: mark more strings for translationstenglong.tl, Jul 21, 2022
  123. 3/6 pack-bitmap.c: rename "idx_name" to "bitmap_name"tenglong.tl, Jul 21, 2022
  124. 4/6 pack-bitmap.c: do not ignore error when opening a bitmap filetenglong.tl, Jul 21, 2022
  125. 5/6 pack-bitmap.c: using error() instead of silently returning -1tenglong.tl, Jul 21, 2022
  126. 6/6 pack-bitmap.c: continue looping when first MIDX bitmap is foundtenglong.tl, Jul 21, 2022
  127. Junio C HamanoJul 21, 2022
  128. tenglong.tlJul 22, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.