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

Re: [PATCH v2 06/14] imap-send.c: remove some unused fields from struct store

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 15, 2013, 22:30 UTC
Message-ID
<7vtxqi13ks.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130115203204.GA12524@google.com>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 54 quoted lines
> Michael Haggerty wrote:
>
>> -			else if ((arg1 = next_arg(&cmd))) {
>> -				if (!strcmp("EXISTS", arg1))
>> -					ctx->gen.count = atoi(arg);
>> -				else if (!strcmp("RECENT", arg1))
>> -					ctx->gen.recent = atoi(arg);
>> +			} else if ((arg1 = next_arg(&cmd))) {
>> +				/* unused */
>
> The above is just the right thing to do to ensure no behavior change.
> Let's take a look at the resulting code, though:
>
> 			if (... various reasonable things ...) {
> 				...
> 			} else if ((arg1 = next_arg(&cmd))) {
> 				/* unused */
> 			} else {
> 				fprintf(stderr, "IMAP error: unable to parse untagged response\n");
> 				return RESP_BAD;
>
> Anyone forced by some bug to examine this "/* unused */" case is going
> to have no clue what's going on.  In that respect, the old code was
> much better, since it at least made it clear that one case where this
> code gets hit is handling "<num> EXISTS" and "<num> RECENT" untagged
> responses.
>
> I suspect that original code did not have an implicit and intended
> missing
>
> 				else
> 					; /* negligible response; ignore it */
>
> but the intent was rather 
>
> 				else {
> 					fprintf(stderr, "IMAP error: I can't parse this\n");
> 					return RESP_BAD;
> 				}
>
> Since actually fixing that is probably too aggressive for this patch,
> how about a FIXME comment like the following?
>
> 		/*
> 		 * Unhandled response-data with at least two words.
> 		 * Ignore it.
> 		 *
> 		 * NEEDSWORK: Previously this case handled '<num> EXISTS'
> 		 * and '<num> RECENT' but as a probably-unintended side
> 		 * effect it ignores other unrecognized two-word
> 		 * responses.  imap-send doesn't ever try to read
> 		 * messages or mailboxes these days, so consider
> 		 * eliminating this case.
> 		 */

Hmph; it seems that it is not worth rerolling the whole thing only for this, so let me squash this in, replacing the /* unused */ with the large comment, and then merge the result to 'next'.

Previous: Jonathan NiederNext: Jonathan Nieder
Message 9 of 25 in “Remove unused code from imap-send.c”
  1. 00/14 Remove unused code from imap-send.cMichael Haggerty, Jan 15, 2013
  2. 01/14 imap-send.c: remove msg_data::flags, which was always zeroMichael Haggerty, Jan 15, 2013
  3. 02/14 imap-send.c: remove struct msg_dataMichael Haggerty, Jan 15, 2013
  4. 03/14 iamp-send.c: remove unused struct imap_store_confMichael Haggerty, Jan 15, 2013
  5. 04/14 imap-send.c: remove struct store_confMichael Haggerty, Jan 15, 2013
  6. 05/14 imap-send.c: remove struct messageMichael Haggerty, Jan 15, 2013
  7. 06/14 imap-send.c: remove some unused fields from struct storeMichael Haggerty, Jan 15, 2013
  8. Jonathan NiederJan 15, 2013
  9. Junio C HamanoJan 15, 2013
  10. Jonathan NiederJan 15, 2013
  11. Michael HaggertyJan 16, 2013
  12. 07/14 imap-send.c: inline imap_parse_list() in imap_list()Michael Haggerty, Jan 15, 2013
  13. Matt KraaiJan 15, 2013
  14. Michael HaggertyJan 16, 2013
  15. Junio C HamanoJan 16, 2013
  16. Michael HaggertyJan 17, 2013
  17. 08/14 imap-send.c: remove struct imap argument to parse_imap_list_l()Michael Haggerty, Jan 15, 2013
  18. 09/14 imap-send.c: remove namespace fields from struct imapMichael Haggerty, Jan 15, 2013
  19. 10/14 imap-send.c: remove unused field imap_store::trashncMichael Haggerty, Jan 15, 2013
  20. 11/14 imap-send.c: use struct imap_store instead of struct storeMichael Haggerty, Jan 15, 2013
  21. 12/14 imap-send.c: remove unused field imap_store::uidvalidityMichael Haggerty, Jan 15, 2013
  22. 13/14 imap-send.c: fold struct store into struct imap_storeMichael Haggerty, Jan 15, 2013
  23. 14/14 imap-send.c: simplify logic in lf_to_crlf()Michael Haggerty, Jan 15, 2013
  24. Jeff KingJan 15, 2013
  25. Jonathan NiederJan 15, 2013

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.