Page MenuHomeFreeBSD

diff3: Produce correct exit status
ClosedPublic

Authored by des on Sun, Mar 1, 7:42 PM.
Tags
None
Referenced Files
F146386832: D55608.diff
Mon, Mar 2, 7:12 AM
F146366143: D55608.id172979.diff
Mon, Mar 2, 2:58 AM
F146359891: D55608.id.diff
Mon, Mar 2, 1:47 AM
F146348727: D55608.id172981.diff
Sun, Mar 1, 11:24 PM
F146344837: D55608.diff
Sun, Mar 1, 10:33 PM
Subscribers

Details

Summary

Use exit status 2 for errors, 1 only to indicate that differences were
found between the inputs (in some operating modes).

MFC after: 1 week
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Sun, Mar 1, 7:42 PM

Not a huge fan of complexity, but would it make sense to turn these into an enum in a later revision for human readability? I'm game for making the change after you're done if you're busy with other things.

ngie accepted this revision.EditedSun, Mar 1, 7:50 PM

Sorry -- forgot to sign-off in my last submission. An answer to my prior question/request shouldn't block this change landing since this change should definitely be made (regardless of how it's expressed) as it makes the code more "functionally correct". A code mod switching 0/1/2 to a structured enum, e.g., DIFF_EX_SAME, DIFF_EX_DIFF, DIFF_EX_ERROR can be done at a later point as part of a larger cleanup/code mod.

This revision is now accepted and ready to land.Sun, Mar 1, 7:50 PM
ngie requested changes to this revision.EditedSun, Mar 1, 8:00 PM

I'm sorry -- it's still too early for my brain to be effective at code reviewing. I'll retract my prior acceptance until we get some clarity on some of the changes (some of the changes going from 1->2 look correct, but I'm not sure about some of the edge cases in skip/readin).

usr.bin/diff3/diff3.c
270–290

Is this the correct exit code to make in these scenarios? Without better inspecting the code, it's hard to grok what it's doing here.

567

Does an error signifier need to be checked prior to this, e.g., feof?

598

We can't determine if it's 1 or 2 without inspecting the descriptors with feof(3).

655

LGTM!

903–923

This all LGTM!

This revision now requires changes to proceed.Sun, Mar 1, 8:00 PM

I suppose we could, but it would be a huge diff that changed nothing.

usr.bin/diff3/diff3.c
270–290

Yes, it means diff is broken and we can't parse its output.

567

No, EOF here is just as much an unrecoverable error as an actual I/O error.

598

Yes we can. We're reading structured data. This error is only reached if the input is invalid.

usr.bin/diff3/diff3.c
270–290

Ok, I reread the comment header for the function, and now better understand what you meant both with your comment and this change.

Being helpful to my past self: these conditionals confirm that the output format for number ranges in diffs are valid. In the event the output is invalid, e.g., contains negative steps like "9-1" (invalid) vs 1-9 (valid), now the code will exit with 2 instead of 1.

567

This is the only area in the diff (now) that I'm potentially unsure about. Is there a way to easily test/confirm this with GNU diff3?

usr.bin/diff3/diff3.1
200–203

I think this is the same thing.

200–203
.Ex -std

would have been the same thing. Not sure how the Additionally, if the part snuck in there.

204–212

Not 100% sold on this rewording, but... just throwing this out there as a potential change.
@ziaee : thoughts?

usr.bin/diff3/diff3.c
567

This function is called when we want to skip over part of the diff we're parsing. If get_line() returns NULL, it means either a broken pipe or incomplete input. Either way, that's an unrecoverable error.

usr.bin/diff3/diff3.1
200–203

No, it isn't the same thing.

This revision is now accepted and ready to land.Mon, Mar 2, 2:44 AM
This revision was automatically updated to reflect the committed changes.