]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tpm2-setup: remove redundant fflush_and_check() 36521/head
authorLennart Poettering <lennart@poettering.net>
Wed, 26 Feb 2025 08:12:39 +0000 (09:12 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 26 Feb 2025 08:13:37 +0000 (09:13 +0100)
The immediately following flink_tmpfile() does that anyway, hence no
need to do so explicitly beforehand.

(Also the log message was wrong: it says "sync" but here we "flush",
which is a much weaker operation)

src/tpm2-setup/tpm2-setup.c

index 43771a28ca213e313efbb7ee3b5f8800aa5abd0f..6a9a7852e29cbf85a567ea25fd93e54728e527e2 100644 (file)
@@ -348,10 +348,6 @@ static int run(int argc, char *argv[]) {
         if (fchmod(fileno(f), 0444) < 0)
                 return log_error_errno(errno, "Failed to adjust access mode of SRK public key file '%s' to 0444: %m", pem_path);
 
-        r = fflush_and_check(f);
-        if (r < 0)
-                return log_error_errno(r, "Failed to sync SRK key to disk: %m");
-
         r = flink_tmpfile(f, t, pem_path, LINK_TMPFILE_SYNC|LINK_TMPFILE_REPLACE);
         if (r < 0)
                 return log_error_errno(r, "Failed to move SRK public key file to '%s': %m", pem_path);
@@ -382,10 +378,6 @@ static int run(int argc, char *argv[]) {
         if (fchmod(fileno(f), 0444) < 0)
                 return log_error_errno(errno, "Failed to adjust access mode of SRK public key file '%s' to 0444: %m", tpm2b_public_path);
 
-        r = fflush_and_check(f);
-        if (r < 0)
-                return log_error_errno(r, "Failed to sync SRK key to disk: %m");
-
         r = flink_tmpfile(f, t, tpm2b_public_path, LINK_TMPFILE_SYNC|LINK_TMPFILE_REPLACE);
         if (r < 0)
                 return log_error_errno(r, "Failed to move SRK public key file to '%s': %m", tpm2b_public_path);