The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=55f160fb07eaee977c89bdee7bdd83f4d21f5adf
commit 55f160fb07eaee977c89bdee7bdd83f4d21f5adf Author: Dag-Erling Smørgrav <[email protected]> AuthorDate: 2026-02-05 14:39:39 +0000 Commit: Dag-Erling Smørgrav <[email protected]> CommitDate: 2026-02-05 14:39:39 +0000 diff: Print an error message on I/O error If an error occurs while atomizing either file, immediately print an error message using the error code returned by the atomizer, and set the error bit in the exit status. PR: 292198 MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: thj, kevans Differential Revision: https://reviews.freebsd.org/D55109 --- usr.bin/diff/diffreg_new.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/usr.bin/diff/diffreg_new.c b/usr.bin/diff/diffreg_new.c index f29e4ad8b9ed..29882923cd0e 100644 --- a/usr.bin/diff/diffreg_new.c +++ b/usr.bin/diff/diffreg_new.c @@ -158,6 +158,7 @@ diffreg_new(char *file1, char *file2, int flags, int capsicum) const struct diff_config *cfg; enum diffreg_algo algo; cap_rights_t rights_ro; + int ret; algo = DIFFREG_ALGO_MYERS_THEN_MYERS_DIVIDE; @@ -219,12 +220,20 @@ diffreg_new(char *file1, char *file2, int flags, int capsicum) if (flags & D_PROTOTYPE) diff_flags |= DIFF_FLAG_SHOW_PROTOTYPES; - if (diff_atomize_file(&left, cfg, f1, (uint8_t *)str1, st1.st_size, diff_flags)) { + ret = diff_atomize_file(&left, cfg, f1, (uint8_t *)str1, st1.st_size, + diff_flags); + if (ret != DIFF_RC_OK) { + warnc(ret, "%s", file1); rc = D_ERROR; + status |= 2; goto done; } - if (diff_atomize_file(&right, cfg, f2, (uint8_t *)str2, st2.st_size, diff_flags)) { + ret = diff_atomize_file(&right, cfg, f2, (uint8_t *)str2, st2.st_size, + diff_flags); + if (ret != DIFF_RC_OK) { + warnc(ret, "%s", file2); rc = D_ERROR; + status |= 2; goto done; }
