extra global and/or non-static variables suck in shared libraries
use "else if" rather than many "return" calls
Signed-off-by: Karel Zak <kzak@redhat.com>
#include "libvolume_id.h"
#include "util.h"
#include "libvolume_id.h"
#include "util.h"
-static struct mdp0_super_block {
+struct mdp0_super_block {
uint32_t md_magic;
uint32_t major_version;
uint32_t minor_version;
uint32_t md_magic;
uint32_t major_version;
uint32_t minor_version;
uint32_t set_uuid1;
uint32_t set_uuid2;
uint32_t set_uuid3;
uint32_t set_uuid1;
uint32_t set_uuid2;
uint32_t set_uuid3;
struct mdp1_super_block {
uint32_t magic;
struct mdp1_super_block {
uint32_t magic;
uint32_t pad0;
uint8_t set_uuid[16];
uint8_t set_name[32];
uint32_t pad0;
uint8_t set_uuid[16];
uint8_t set_name[32];
#define MD_RESERVED_BYTES 0x10000
#define MD_SB_MAGIC 0xa92b4efc
#define MD_RESERVED_BYTES 0x10000
#define MD_SB_MAGIC 0xa92b4efc
static int volume_id_probe_linux_raid0(struct volume_id *id, uint64_t off, uint64_t size)
{
const uint8_t *buf;
static int volume_id_probe_linux_raid0(struct volume_id *id, uint64_t off, uint64_t size)
{
const uint8_t *buf;
+ struct mdp0_super_block *mdp0;
union {
uint32_t ints[4];
uint8_t bytes[16];
union {
uint32_t ints[4];
uint8_t bytes[16];
static int volume_id_probe_linux_raid1(struct volume_id *id, uint64_t off, uint64_t size)
{
const uint8_t *buf;
static int volume_id_probe_linux_raid1(struct volume_id *id, uint64_t off, uint64_t size)
{
const uint8_t *buf;
+ struct mdp1_super_block *mdp1;
info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
info("probing at offset 0x%llx, size 0x%llx\n",
(unsigned long long) off, (unsigned long long) size);
/* version 1.0 at the end of the device */
sboff = (size & ~(0x1000 - 1)) - 0x2000;
/* version 1.0 at the end of the device */
sboff = (size & ~(0x1000 - 1)) - 0x2000;
- if (volume_id_probe_linux_raid1(id, off + sboff, size) == 0) {
+ if (volume_id_probe_linux_raid1(id, off + sboff, size) == 0)
strcpy(id->type_version, "1.0");
strcpy(id->type_version, "1.0");
/* version 1.1 at the start of the device */
/* version 1.1 at the start of the device */
- if (volume_id_probe_linux_raid1(id, off, size) == 0) {
+ else if (volume_id_probe_linux_raid1(id, off, size) == 0)
strcpy(id->type_version, "1.1");
strcpy(id->type_version, "1.1");
/* version 1.2 at 4k offset from the start */
/* version 1.2 at 4k offset from the start */
- if (volume_id_probe_linux_raid1(id, off + 0x1000, size) == 0) {
+ else if (volume_id_probe_linux_raid1(id, off + 0x1000, size) == 0)
strcpy(id->type_version, "1.2");
strcpy(id->type_version, "1.2");
+ else
+ return -1;
+
+ return 0;