Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 May 2021 14:12:41 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 3f2508b7f385 - main - elfctl: avoid touching file if no change made
Message-ID:  <202105261412.14QECfax042702@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f2508b7f3855102abed99b846e30e728ba3d04d

commit 3f2508b7f3855102abed99b846e30e728ba3d04d
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2021-05-25 18:25:18 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2021-05-26 14:12:12 +0000

    elfctl: avoid touching file if no change made
    
    Suggested by:   brooks
    Reviewed by:    brooks, markj
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D30452
---
 usr.bin/elfctl/elfctl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/usr.bin/elfctl/elfctl.c b/usr.bin/elfctl/elfctl.c
index 41660fc4acd5..ef7f915ded30 100644
--- a/usr.bin/elfctl/elfctl.c
+++ b/usr.bin/elfctl/elfctl.c
@@ -291,7 +291,7 @@ convert_to_feature_val(char *feature_str, uint32_t *feature_val)
 static bool
 edit_file_features(Elf *elf, int phcount, int fd, char *val, bool endian_swap)
 {
-	uint32_t features;
+	uint32_t features, prev_features;
 	uint64_t off;
 
 	if (!get_file_features(elf, phcount, fd, &features, &off,
@@ -300,8 +300,12 @@ edit_file_features(Elf *elf, int phcount, int fd, char *val, bool endian_swap)
 		return (false);
 	}
 
+	prev_features = features;
 	if (!convert_to_feature_val(val, &features))
 		return (false);
+	/* Avoid touching file if no change. */
+	if (features == prev_features)
+		return (true);
 
 	if (endian_swap)
 		features = bswap32(features);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105261412.14QECfax042702>