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

Re: [PATCH 1/3] fetch.c: clear errno before calling functions that might set it

From
Ronnie Sahlberg <sahlberg@google.com>
Date
Apr 24, 2014, 15:21 UTC
Message-ID
<CAL=YDWk9xd3d4Z8YoXvy7Z=5q=3=6+s_KaBS3W0yyESZ=ueDSA@mail.gmail.com>
In-Reply-To
<CAPig+cTu4hUCF4r6wAHnGpfcoQP9SqDUWgA2SjjKbjDNrDG8fg@mail.gmail.com>
Fixed. Thanks.
On Wed, Apr 23, 2014 at 1:12 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 43 quoted lines
> On Tue, Apr 22, 2014 at 2:45 PM, Ronnie Sahlberg <sahlberg@google.com> wrote:
>> In s_update_ref there are two calls that when they fail we return an error
>> based on the errno value. In particular we want to return a specific error
>> if ENOTDIR happened. Both these functions do have failure modes where they
>> may return an error without updating errno, in which case a previous and
>> unrelated ENOTDIT may cause us to return the wrong error. Clear errno before
>> calling any functions if we check errno afterwards.
>>
>> Also skip initializing a static variable to 0. Sstatics live in .bss and
>
> s/Sstatics/Statics/
>
>> are all automatically initialized to 0.
>>
>> Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
>> ---
>>  builtin/fetch.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/builtin/fetch.c b/builtin/fetch.c
>> index 55f457c..a93c893 100644
>> --- a/builtin/fetch.c
>> +++ b/builtin/fetch.c
>> @@ -44,7 +44,7 @@ static struct transport *gtransport;
>>  static struct transport *gsecondary;
>>  static const char *submodule_prefix = "";
>>  static const char *recurse_submodules_default;
>> -static int shown_url = 0;
>> +static int shown_url;
>>
>>  static int option_parse_recurse_submodules(const struct option *opt,
>>                                    const char *arg, int unset)
>> @@ -382,6 +382,8 @@ static int s_update_ref(const char *action,
>>         if (!rla)
>>                 rla = default_rla.buf;
>>         snprintf(msg, sizeof(msg), "%s: %s", rla, action);
>> +
>> +       errno = 0;
>>         lock = lock_any_ref_for_update(ref->name,
>>                                        check_old ? ref->old_sha1 : NULL,
>>                                        0, NULL);
>> --
>> 1.9.1.518.g16976cb.dirty
Previous: Eric SunshineNext: Ronnie Sahlberg
Message 4 of 14 in “Use ref transactions for fetch”
  1. 0/3 Use ref transactions for fetchRonnie Sahlberg, Apr 22, 2014
  2. 1/3 fetch.c: clear errno before calling functions that might set itRonnie Sahlberg, Apr 22, 2014
  3. Eric SunshineApr 23, 2014
  4. Ronnie SahlbergApr 24, 2014
  5. 2/3 fetch.c: change s_update_ref to use a ref transactionRonnie Sahlberg, Apr 22, 2014
  6. Eric SunshineApr 23, 2014
  7. Ronnie SahlbergApr 24, 2014
  8. 3/3 fetch.c: use a single ref transaction for all ref updatesRonnie Sahlberg, Apr 22, 2014
  9. Eric SunshineApr 23, 2014
  10. Ronnie SahlbergApr 24, 2014
  11. Michael HaggertyMay 5, 2014
  12. Ronnie SahlbergMay 5, 2014
  13. Junio C HamanoMay 6, 2014
  14. Michael HaggertyMay 6, 2014

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.