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

Re: [PATCH 1/2] mingw: apply array.cocci rule

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 4, 2019, 23:36 UTC
Message-ID
<xmqq36hbskg6.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<nycvar.QRO.7.76.6.1909042340520.5377@tvgsbejvaqbjf.bet>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 52 quoted lines
> Hi Denton,
>
> On Wed, 4 Sep 2019, Denton Liu wrote:
>
>> After running Coccinelle on all sources inside compat/ that were created
>> by us[1], it was found that compat/mingw.c violated an array.cocci rule
>> in two places and, thus, a patch was generated. Apply this patch so that
>> all compat/ sources created by us follows all cocci rules.
>>
>> [1]: Do not run Coccinelle on files that are taken from some upstream
>> because in case we need to pull updates from them, we would like to have
>> diverged as little as possible in order to make merging updates simpler.
>>
>> The following sources were determined to have been taken from some
>> upstream:
>>
>> * compat/regex/
>> * compat/inet_ntop.c
>> * compat/inet_pton.c
>> * compat/nedmalloc/
>> * compat/obstack.{c,h}
>> * compat/poll/
>>
>> Signed-off-by: Denton Liu <liu.denton@gmail.com>
>> ---
>>  compat/mingw.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/compat/mingw.c b/compat/mingw.c
>> index 738f0a826a..a3b1e9e3bb 100644
>> --- a/compat/mingw.c
>> +++ b/compat/mingw.c
>> @@ -1265,7 +1265,7 @@ static wchar_t *make_environment_block(char **deltaenv)
>>  		}
>>
>>  		ALLOC_ARRAY(result, size);
>> -		memcpy(result, wenv, size * sizeof(*wenv));
>> +		COPY_ARRAY(result, wenv, size);
>>  		FreeEnvironmentStringsW(wenv);
>>  		return result;
>>  	}
>> @@ -1309,7 +1309,7 @@ static wchar_t *make_environment_block(char **deltaenv)
>>  			continue;
>>
>>  		size = wcslen(array[i]) + 1;
>> -		memcpy(p, array[i], size * sizeof(*p));
>> +		COPY_ARRAY(p, array[i], size);
>
> ACK!
>
> Thanks,
> Dscho
Yup, looks good.  Thanks both.
Previous: Johannes SchindelinNext: Denton Liu
Message 4 of 8 in “cleanup compat/ sources using spatch”
  1. 0/2 cleanup compat/ sources using spatchDenton Liu, Sep 4, 2019
  2. 1/2 mingw: apply array.cocci ruleDenton Liu, Sep 4, 2019
  3. Johannes SchindelinSep 4, 2019
  4. Junio C HamanoSep 4, 2019
  5. 2/2 compat/*.[ch]: remove extern from function declarations using spatchDenton Liu, Sep 4, 2019
  6. Johannes SchindelinSep 4, 2019
  7. Denton LiuSep 5, 2019
  8. Johannes SchindelinSep 9, 2019

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.