2008-09-15 12:03:30

by Karel Zak

[permalink] [raw]
Subject: [PATCH] libblki: fix s_feature_compat usage

Note that this patch also fix minor coding still errors.

Signed-off-by: Karel Zak <[email protected]>
---
lib/blkid/probe.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index 10ac803..7bb7470 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -150,7 +150,7 @@ static void get_ext2_info(blkid_dev dev, struct blkid_magic *id,

set_uuid(dev, es->s_uuid, 0);

- if ((es->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
+ if ((blkid_le32(es->s_feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
!uuid_is_null(es->s_journal_uuid))
set_uuid(dev, es->s_journal_uuid, "EXT_JOURNAL");

@@ -171,7 +171,7 @@ static int fs_proc_check(const char *fs_name)

f = fopen("/proc/filesystems", "r");
if (!f)
- return (0);
+ return 0;
while (!feof(f)) {
if (!fgets(buf, sizeof(buf), f))
break;
@@ -190,11 +190,11 @@ static int fs_proc_check(const char *fs_name)
*t = 0;
if (!strcmp(fs_name, cp)) {
fclose(f);
- return (1);
+ return 1;
}
}
fclose(f);
- return (0);
+ return 0;
}

/*
@@ -209,12 +209,12 @@ static int check_for_modules(const char *fs_name)
int i;

if (uname(&uts))
- return (0);
+ return 0;
snprintf(buf, sizeof(buf), "/lib/modules/%s/modules.dep", uts.release);

f = fopen(buf, "r");
if (!f)
- return (0);
+ return 0;
while (!feof(f)) {
if (!fgets(buf, sizeof(buf), f))
break;
@@ -231,10 +231,10 @@ static int check_for_modules(const char *fs_name)
*t = 0;
}
if (!strcmp(cp, fs_name))
- return (1);
+ return 1;
}
fclose(f);
- return (0);
+ return 0;
}

static int system_supports_ext4(void)
@@ -1567,7 +1567,7 @@ int main(int argc, char **argv)
dev = blkid_get_dev(cache, argv[1], BLKID_DEV_NORMAL);
if (!dev) {
printf("%s: %s has an unsupported type\n", argv[0], argv[1]);
- return (1);
+ return 1;
}
printf("TYPE='%s'\n", dev->bid_type ? dev->bid_type : "(null)");
if (dev->bid_label)
@@ -1576,6 +1576,6 @@ int main(int argc, char **argv)
printf("UUID='%s'\n", dev->bid_uuid);

blkid_free_dev(dev);
- return (0);
+ return 0;
}
#endif
--
1.5.5.1



2008-09-15 23:11:04

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH] libblki: fix s_feature_compat usage

On Sep 15, 2008 14:03 +0200, Karel Zak wrote:
> Note that this patch also fix minor coding still errors.
>
> @@ -150,7 +150,7 @@ static void get_ext2_info(blkid_dev dev, struct blkid_magic *id,
>
> set_uuid(dev, es->s_uuid, 0);
>
> - if ((es->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
> + if ((blkid_le32(es->s_feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&

Minor note - it is generally preferable to swab the constant value,
since this can be done at compile time instead of runtime.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.


2008-09-15 23:36:48

by Karel Zak

[permalink] [raw]
Subject: Re: [PATCH] libblki: fix s_feature_compat usage

On Mon, Sep 15, 2008 at 04:11:02PM -0700, Andreas Dilger wrote:
> On Sep 15, 2008 14:03 +0200, Karel Zak wrote:
> > Note that this patch also fix minor coding still errors.

oops, s/still/style/ :-(

> > @@ -150,7 +150,7 @@ static void get_ext2_info(blkid_dev dev, struct blkid_magic *id,
> >
> > set_uuid(dev, es->s_uuid, 0);
> >
> > - if ((es->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
> > + if ((blkid_le32(es->s_feature_compat) & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
>
> Minor note - it is generally preferable to swab the constant value,

probably yes, but see the rest of the library code... :-)

Karel

--
Karel Zak <[email protected]>