]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
chattr-util: use BIT_FOREACH where appropriate
authorMike Yuan <me@yhndnzj.com>
Sat, 7 Sep 2024 00:44:24 +0000 (02:44 +0200)
committerMike Yuan <me@yhndnzj.com>
Sat, 7 Sep 2024 12:46:18 +0000 (14:46 +0200)
src/basic/chattr-util.c

index 02d2cc2e526253dca36b8cb1088ee52435ead815..9677e9a35a99b1952f34aae99789810edadcd76a 100644 (file)
@@ -6,6 +6,7 @@
 #include <sys/stat.h>
 #include <linux/fs.h>
 
+#include "bitfield.h"
 #include "chattr-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
@@ -93,11 +94,9 @@ int chattr_full(
          * supported, and we can ignore it too */
 
         unsigned current_attr = old_attr;
-        for (unsigned i = 0; i < sizeof(unsigned) * 8; i++) {
-                unsigned new_one, mask_one = 1u << i;
 
-                if (!FLAGS_SET(mask, mask_one))
-                        continue;
+        BIT_FOREACH(i, mask) {
+                unsigned new_one, mask_one = 1u << i;
 
                 new_one = UPDATE_FLAG(current_attr, mask_one, FLAGS_SET(value, mask_one));
                 if (new_one == current_attr)