From: Stefan Sperling Subject: Re: diff.git: Fix ed script output To: Tom Jones Cc: gameoftrees@openbsd.org Date: Tue, 6 Sep 2022 11:00:13 +0200 On Tue, Sep 06, 2022 at 09:38:59AM +0100, Tom Jones wrote: > + rc = fprintf(dest, ".\n"); > + if (rc != DIFF_RC_OK) > + return rc; DIFF_RC_OK is not a valid return code of fprintf. > + if (outinfo) { > + ARRAYLIST_ADD(offp, outinfo->line_offsets); > + if (offp == NULL) > + return ENOMEM; > + outoff += rc; > + *offp = *outoff; > + } > + } > + if (rc) > + return rc; The check for success (rc < 0 means error) should happen earlier, before the new line offset is computed based on the return code (amount of bytes written to the file if not < 0).