Re: [RFC PATCH 2/2] notes.c: fixed tip when target and append note are both empty
- From
Teng Long <dyroneteng@gmail.com>
- Date
- Oct 18, 2022, 03:25 UTC
- Message-ID
- <20221018032523.74253-1-tenglong.tl@alibaba-inc.com>
- In-Reply-To
- <c0211f35-bb26-7ca8-6f9d-a62507e55e8a@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
> I don't think its written to if we take the 'else if' branch added by > this patch so we need to initialize it for the free() at the end.
Actually, I didn't get it totally (maybe because my English, sorry for that), but indeed the 'else if' expose this problem out, so I think to initialize it is needed.
Thanks.
Show 10 quoted lines
> We only seem to be using cp.buf.len so we can test check if the original > note was empty so I think it would be better just to add > > int note_was_empty; > > ` ... > > note_was_empty = !d.buf.len > > instead.
Yes, it actually does as you describe above, your suggestion makes it look better.
Thank you very much for your detailed review.