summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2016-06-14 13:55:27 +0200
committerKarel Zak2016-06-14 14:39:16 +0200
commit7f787ced5d401ccd56a82bb2b1202f1ea7164783 (patch)
tree2156288adc10a43c9509f1378fe60597f994e02f
parentlibmount: don't check nonnull attributes for NULL [-Wnonnull-compare] (diff)
downloadkernel-qcow2-util-linux-7f787ced5d401ccd56a82bb2b1202f1ea7164783.tar.gz
kernel-qcow2-util-linux-7f787ced5d401ccd56a82bb2b1202f1ea7164783.tar.xz
kernel-qcow2-util-linux-7f787ced5d401ccd56a82bb2b1202f1ea7164783.zip
libblkid: don't check nonnull attributes for NULL [-Wnonnull-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--libblkid/src/blkid.h.in142
-rw-r--r--libblkid/src/partitions/partitions.c48
-rw-r--r--libblkid/src/probe.c106
-rw-r--r--libblkid/src/read.c3
-rw-r--r--libblkid/src/save.c3
-rw-r--r--libblkid/src/superblocks/superblocks.c10
-rw-r--r--libblkid/src/tag.c6
-rw-r--r--libblkid/src/topology/topology.c4
8 files changed, 135 insertions, 187 deletions
diff --git a/libblkid/src/blkid.h.in b/libblkid/src/blkid.h.in
index 4f5fe2ae5..d7bbced7f 100644
--- a/libblkid/src/blkid.h.in
+++ b/libblkid/src/blkid.h.in
@@ -218,13 +218,15 @@ extern char *blkid_evaluate_spec(const char *spec, blkid_cache *cache)
extern blkid_probe blkid_new_probe(void)
__ul_attribute__((warn_unused_result));
extern blkid_probe blkid_new_probe_from_filename(const char *filename)
- __ul_attribute__((warn_unused_result));
+ __ul_attribute__((warn_unused_result))
+ __ul_attribute__((nonnull));
extern void blkid_free_probe(blkid_probe pr);
extern void blkid_reset_probe(blkid_probe pr);
extern int blkid_probe_set_device(blkid_probe pr, int fd,
- blkid_loff_t off, blkid_loff_t size);
+ blkid_loff_t off, blkid_loff_t size)
+ __ul_attribute__((nonnull));
extern dev_t blkid_probe_get_devno(blkid_probe pr)
__ul_attribute__((nonnull));
@@ -235,21 +237,28 @@ extern dev_t blkid_probe_get_wholedisk_devno(blkid_probe pr)
extern int blkid_probe_is_wholedisk(blkid_probe pr)
__ul_attribute__((nonnull));
-extern blkid_loff_t blkid_probe_get_size(blkid_probe pr);
-extern blkid_loff_t blkid_probe_get_offset(blkid_probe pr);
-extern unsigned int blkid_probe_get_sectorsize(blkid_probe pr);
-extern blkid_loff_t blkid_probe_get_sectors(blkid_probe pr);
+extern blkid_loff_t blkid_probe_get_size(blkid_probe pr)
+ __ul_attribute__((nonnull));
+extern blkid_loff_t blkid_probe_get_offset(blkid_probe pr)
+ __ul_attribute__((nonnull));
+extern unsigned int blkid_probe_get_sectorsize(blkid_probe pr)
+ __ul_attribute__((nonnull));
+extern blkid_loff_t blkid_probe_get_sectors(blkid_probe pr)
+ __ul_attribute__((nonnull));
-extern int blkid_probe_get_fd(blkid_probe pr);
+extern int blkid_probe_get_fd(blkid_probe pr)
+ __ul_attribute__((nonnull));
/*
* superblocks probing
*/
-extern int blkid_known_fstype(const char *fstype);
+extern int blkid_known_fstype(const char *fstype)
+ __ul_attribute__((nonnull));
extern int blkid_superblocks_get_name(size_t idx, const char **name, int *usage);
-extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable);
+extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
+ __ul_attribute__((nonnull));
#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
@@ -265,9 +274,12 @@ extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable);
#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
-extern int blkid_probe_set_superblocks_flags(blkid_probe pr, int flags);
-extern int blkid_probe_reset_superblocks_filter(blkid_probe pr);
-extern int blkid_probe_invert_superblocks_filter(blkid_probe pr);
+extern int blkid_probe_set_superblocks_flags(blkid_probe pr, int flags)
+ __ul_attribute__((nonnull));
+extern int blkid_probe_reset_superblocks_filter(blkid_probe pr)
+ __ul_attribute__((nonnull));
+extern int blkid_probe_invert_superblocks_filter(blkid_probe pr)
+ __ul_attribute__((nonnull));
/**
* BLKID_FLTR_NOTIN
@@ -277,21 +289,25 @@ extern int blkid_probe_invert_superblocks_filter(blkid_probe pr);
* BLKID_FLTR_ONLYIN
*/
#define BLKID_FLTR_ONLYIN 2
-extern int blkid_probe_filter_superblocks_type(blkid_probe pr, int flag, char *names[]);
+extern int blkid_probe_filter_superblocks_type(blkid_probe pr, int flag, char *names[])
+ __ul_attribute__((nonnull));
#define BLKID_USAGE_FILESYSTEM (1 << 1)
#define BLKID_USAGE_RAID (1 << 2)
#define BLKID_USAGE_CRYPTO (1 << 3)
#define BLKID_USAGE_OTHER (1 << 4)
-extern int blkid_probe_filter_superblocks_usage(blkid_probe pr, int flag, int usage);
+extern int blkid_probe_filter_superblocks_usage(blkid_probe pr, int flag, int usage)
+ __ul_attribute__((nonnull));
/*
* topology probing
*/
-extern int blkid_probe_enable_topology(blkid_probe pr, int enable);
+extern int blkid_probe_enable_topology(blkid_probe pr, int enable)
+ __ul_attribute__((nonnull));
/* binary interface */
-extern blkid_topology blkid_probe_get_topology(blkid_probe pr);
+extern blkid_topology blkid_probe_get_topology(blkid_probe pr)
+ __ul_attribute__((nonnull));
extern unsigned long blkid_topology_get_alignment_offset(blkid_topology tp)
__ul_attribute__((nonnull));
@@ -309,39 +325,55 @@ extern unsigned long blkid_topology_get_physical_sector_size(blkid_topology tp)
*/
extern int blkid_known_pttype(const char *pttype);
-extern int blkid_probe_enable_partitions(blkid_probe pr, int enable);
+extern int blkid_probe_enable_partitions(blkid_probe pr, int enable)
+ __ul_attribute__((nonnull));
-extern int blkid_probe_reset_partitions_filter(blkid_probe pr);
-extern int blkid_probe_invert_partitions_filter(blkid_probe pr);
-extern int blkid_probe_filter_partitions_type(blkid_probe pr, int flag, char *names[]);
+extern int blkid_probe_reset_partitions_filter(blkid_probe pr)
+ __ul_attribute__((nonnull));
+extern int blkid_probe_invert_partitions_filter(blkid_probe pr)
+ __ul_attribute__((nonnull));
+extern int blkid_probe_filter_partitions_type(blkid_probe pr, int flag, char *names[])
+ __ul_attribute__((nonnull));
/* partitions probing flags */
#define BLKID_PARTS_FORCE_GPT (1 << 1)
#define BLKID_PARTS_ENTRY_DETAILS (1 << 2)
#define BLKID_PARTS_MAGIC (1 << 3)
-extern int blkid_probe_set_partitions_flags(blkid_probe pr, int flags);
+extern int blkid_probe_set_partitions_flags(blkid_probe pr, int flags)
+ __ul_attribute__((nonnull));
/* binary interface */
-extern blkid_partlist blkid_probe_get_partitions(blkid_probe pr);
+extern blkid_partlist blkid_probe_get_partitions(blkid_probe pr)
+ __ul_attribute__((nonnull));
-extern int blkid_partlist_numof_partitions(blkid_partlist ls);
-extern blkid_parttable blkid_partlist_get_table(blkid_partlist ls);
-extern blkid_partition blkid_partlist_get_partition(blkid_partlist ls, int n);
-extern blkid_partition blkid_partlist_get_partition_by_partno(blkid_partlist ls, int n);
-extern blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno);
-extern blkid_parttable blkid_partition_get_table(blkid_partition par);
+extern int blkid_partlist_numof_partitions(blkid_partlist ls)
+ __ul_attribute__((nonnull));
+extern blkid_parttable blkid_partlist_get_table(blkid_partlist ls)
+ __ul_attribute__((nonnull));
+extern blkid_partition blkid_partlist_get_partition(blkid_partlist ls, int n)
+ __ul_attribute__((nonnull));
+extern blkid_partition blkid_partlist_get_partition_by_partno(blkid_partlist ls, int n)
+ __ul_attribute__((nonnull));
+extern blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno)
+ __ul_attribute__((nonnull));
+extern blkid_parttable blkid_partition_get_table(blkid_partition par)
+ __ul_attribute__((nonnull));
-extern const char *blkid_partition_get_name(blkid_partition par);
-extern const char *blkid_partition_get_uuid(blkid_partition par);
-extern int blkid_partition_get_partno(blkid_partition par);
-extern blkid_loff_t blkid_partition_get_start(blkid_partition par);
-extern blkid_loff_t blkid_partition_get_size(blkid_partition par);
+extern const char *blkid_partition_get_name(blkid_partition par)
+ __ul_attribute__((nonnull));
+extern const char *blkid_partition_get_uuid(blkid_partition par)
+ __ul_attribute__((nonnull));
+extern int blkid_partition_get_partno(blkid_partition par)
+ __ul_attribute__((nonnull));
+extern blkid_loff_t blkid_partition_get_start(blkid_partition par)
+ __ul_attribute__((nonnull));
+extern blkid_loff_t blkid_partition_get_size(blkid_partition par)
+ __ul_attribute__((nonnull));
extern int blkid_partition_get_type(blkid_partition par)
__ul_attribute__((nonnull));
-
-extern const char *blkid_partition_get_type_string(blkid_partition par);
-
+extern const char *blkid_partition_get_type_string(blkid_partition par)
+ __ul_attribute__((nonnull));
extern unsigned long long blkid_partition_get_flags(blkid_partition par)
__ul_attribute__((nonnull));
@@ -352,29 +384,39 @@ extern int blkid_partition_is_extended(blkid_partition par)
extern int blkid_partition_is_primary(blkid_partition par)
__ul_attribute__((nonnull));
-extern const char *blkid_parttable_get_type(blkid_parttable tab);
-extern const char *blkid_parttable_get_id(blkid_parttable tab);
-
-extern blkid_loff_t blkid_parttable_get_offset(blkid_parttable tab);
-extern blkid_partition blkid_parttable_get_parent(blkid_parttable tab);
+extern const char *blkid_parttable_get_type(blkid_parttable tab)
+ __ul_attribute__((nonnull));
+extern const char *blkid_parttable_get_id(blkid_parttable tab)
+ __ul_attribute__((nonnull));
+extern blkid_loff_t blkid_parttable_get_offset(blkid_parttable tab)
+ __ul_attribute__((nonnull));
+extern blkid_partition blkid_parttable_get_parent(blkid_parttable tab)
+ __ul_attribute__((nonnull));
/*
* NAME=value low-level interface
*/
-extern int blkid_do_probe(blkid_probe pr);
-extern int blkid_do_safeprobe(blkid_probe pr);
-extern int blkid_do_fullprobe(blkid_probe pr);
+extern int blkid_do_probe(blkid_probe pr)
+ __ul_attribute__((nonnull));
+extern int blkid_do_safeprobe(blkid_probe pr)
+ __ul_attribute__((nonnull));
+extern int blkid_do_fullprobe(blkid_probe pr)
+ __ul_attribute__((nonnull));
-extern int blkid_probe_numof_values(blkid_probe pr);
+extern int blkid_probe_numof_values(blkid_probe pr)
+ __ul_attribute__((nonnull));
extern int blkid_probe_get_value(blkid_probe pr, int num, const char **name,
- const char **data, size_t *len);
+ const char **data, size_t *len)
+ __ul_attribute__((nonnull(1)));
extern int blkid_probe_lookup_value(blkid_probe pr, const char *name,
- const char **data, size_t *len);
+ const char **data, size_t *len)
+ __ul_attribute__((nonnull(1, 2)));
extern int blkid_probe_has_value(blkid_probe pr, const char *name)
__ul_attribute__((nonnull));
-
-extern int blkid_do_wipe(blkid_probe pr, int dryrun);
-extern int blkid_probe_step_back(blkid_probe pr);
+extern int blkid_do_wipe(blkid_probe pr, int dryrun)
+ __ul_attribute__((nonnull));
+extern int blkid_probe_step_back(blkid_probe pr)
+ __ul_attribute__((nonnull));
/*
* Deprecated functions/macros
diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c
index 10d6e9182..806fced80 100644
--- a/libblkid/src/partitions/partitions.c
+++ b/libblkid/src/partitions/partitions.c
@@ -213,8 +213,6 @@ static int blkid_partitions_probe_partition(blkid_probe pr);
*/
int blkid_probe_enable_partitions(blkid_probe pr, int enable)
{
- if (!pr)
- return -1;
pr->chains[BLKID_CHAIN_PARTS].enabled = enable;
return 0;
}
@@ -230,8 +228,6 @@ int blkid_probe_enable_partitions(blkid_probe pr, int enable)
*/
int blkid_probe_set_partitions_flags(blkid_probe pr, int flags)
{
- if (!pr)
- return -1;
pr->chains[BLKID_CHAIN_PARTS].flags = flags;
return 0;
}
@@ -898,7 +894,7 @@ int blkid_known_pttype(const char *pttype)
*/
int blkid_partlist_numof_partitions(blkid_partlist ls)
{
- return ls ? ls->nparts : -1;
+ return ls->nparts;
}
/**
@@ -910,7 +906,7 @@ int blkid_partlist_numof_partitions(blkid_partlist ls)
*/
blkid_parttable blkid_partlist_get_table(blkid_partlist ls)
{
- if (!ls || list_empty(&ls->l_tabs))
+ if (list_empty(&ls->l_tabs))
return NULL;
return list_entry(ls->l_tabs.next,
@@ -933,7 +929,7 @@ blkid_parttable blkid_partlist_get_table(blkid_partlist ls)
*/
blkid_partition blkid_partlist_get_partition(blkid_partlist ls, int n)
{
- if (!ls || n < 0 || n >= ls->nparts)
+ if (n < 0 || n >= ls->nparts)
return NULL;
return &ls->parts[n];
@@ -955,9 +951,6 @@ blkid_partition blkid_partlist_get_partition_by_partno(blkid_partlist ls, int n)
int i, nparts;
blkid_partition par;
- if (!ls)
- return NULL;
-
nparts = blkid_partlist_numof_partitions(ls);
for (i = 0; i < nparts; i++) {
par = blkid_partlist_get_partition(ls, i);
@@ -987,9 +980,6 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
uint64_t start, size;
int i, rc, partno = 0;
- if (!ls)
- return NULL;
-
DBG(LOWPROBE, ul_debug("trying to convert devno 0x%llx to partition",
(long long) devno));
@@ -1136,14 +1126,12 @@ int blkid_partitions_strcpy_ptuuid(blkid_probe pr, char *str)
*/
const char *blkid_parttable_get_id(blkid_parttable tab)
{
- return tab && *tab->id ? tab->id : NULL;
+ return *tab->id ? tab->id : NULL;
}
int blkid_partition_set_type(blkid_partition par, int type)
{
- if (!par)
- return -1;
par->type = type;
return 0;
}
@@ -1156,7 +1144,7 @@ int blkid_partition_set_type(blkid_partition par, int type)
*/
const char *blkid_parttable_get_type(blkid_parttable tab)
{
- return tab ? tab->type : NULL;
+ return tab->type;
}
/**
@@ -1167,7 +1155,7 @@ const char *blkid_parttable_get_type(blkid_parttable tab)
*/
blkid_partition blkid_parttable_get_parent(blkid_parttable tab)
{
- return tab ? tab->parent : NULL;
+ return tab->parent;
}
/**
@@ -1196,7 +1184,7 @@ blkid_partition blkid_parttable_get_parent(blkid_parttable tab)
*/
blkid_loff_t blkid_parttable_get_offset(blkid_parttable tab)
{
- return tab ? (blkid_loff_t)tab->offset : -1;
+ return (blkid_loff_t)tab->offset;
}
/**
@@ -1232,7 +1220,7 @@ blkid_loff_t blkid_parttable_get_offset(blkid_parttable tab)
*/
blkid_parttable blkid_partition_get_table(blkid_partition par)
{
- return par ? par->tab : NULL;
+ return par->tab;
}
static int partition_get_logical_type(blkid_partition par)
@@ -1361,7 +1349,7 @@ int blkid_partition_gen_uuid(blkid_partition par)
*/
const char *blkid_partition_get_name(blkid_partition par)
{
- return par && *par->name ? (char *) par->name : NULL;
+ return *par->name ? (char *) par->name : NULL;
}
/**
@@ -1372,7 +1360,7 @@ const char *blkid_partition_get_name(blkid_partition par)
*/
const char *blkid_partition_get_uuid(blkid_partition par)
{
- return par && *par->uuid ? par->uuid : NULL;
+ return *par->uuid ? par->uuid : NULL;
}
/**
@@ -1384,7 +1372,7 @@ const char *blkid_partition_get_uuid(blkid_partition par)
*/
int blkid_partition_get_partno(blkid_partition par)
{
- return par ? par->partno : -1;
+ return par->partno;
}
/**
@@ -1407,7 +1395,7 @@ int blkid_partition_get_partno(blkid_partition par)
*/
blkid_loff_t blkid_partition_get_start(blkid_partition par)
{
- return par ? (blkid_loff_t)par->start : -1;
+ return (blkid_loff_t)par->start;
}
/**
@@ -1428,7 +1416,7 @@ blkid_loff_t blkid_partition_get_start(blkid_partition par)
*/
blkid_loff_t blkid_partition_get_size(blkid_partition par)
{
- return par ? (blkid_loff_t)par->size : -1;
+ return (blkid_loff_t)par->size;
}
/**
@@ -1448,9 +1436,6 @@ int blkid_partition_get_type(blkid_partition par)
int blkid_partition_set_type_string(blkid_partition par,
const unsigned char *type, size_t len)
{
- if (!par)
- return -1;
-
set_string((unsigned char *) par->typestr,
sizeof(par->typestr), type, len);
return 0;
@@ -1461,9 +1446,6 @@ int blkid_partition_set_type_string(blkid_partition par,
*/
int blkid_partition_set_type_uuid(blkid_partition par, const unsigned char *uuid)
{
- if (!par)
- return -1;
-
blkid_unparse_uuid(uuid, par->typestr, sizeof(par->typestr));
return 0;
}
@@ -1480,14 +1462,12 @@ int blkid_partition_set_type_uuid(blkid_partition par, const unsigned char *uuid
*/
const char *blkid_partition_get_type_string(blkid_partition par)
{
- return par && *par->typestr ? par->typestr : NULL;
+ return *par->typestr ? par->typestr : NULL;
}
int blkid_partition_set_flags(blkid_partition par, unsigned long long flags)
{
- if (!par)
- return -1;
par->flags = flags;
return 0;
}
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 72a27f410..d7a3ba7cf 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -214,9 +214,6 @@ blkid_probe blkid_new_probe_from_filename(const char *filename)
int fd = -1;
blkid_probe pr = NULL;
- if (!filename)
- return NULL;
-
fd = open(filename, O_RDONLY|O_CLOEXEC);
if (fd < 0)
return NULL;
@@ -289,7 +286,7 @@ void blkid_probe_chain_reset_values(blkid_probe pr, struct blkid_chain *chn)
struct list_head *p, *pnext;
- if (!pr || list_empty(&pr->values))
+ if (list_empty(&pr->values))
return;
DBG(LOWPROBE, ul_debug("Resetting %s values", chn->driver->name));
@@ -305,8 +302,7 @@ void blkid_probe_chain_reset_values(blkid_probe pr, struct blkid_chain *chn)
static void blkid_probe_chain_reset_position(struct blkid_chain *chn)
{
- if (chn)
- chn->idx = -1;
+ chn->idx = -1;
}
/*
@@ -400,9 +396,6 @@ void *blkid_probe_get_binary_data(blkid_probe pr, struct blkid_chain *chn)
int rc, org_prob_flags;
struct blkid_chain *org_chn;
- if (!pr || !chn)
- return NULL;
-
/* save the current setting -- the binary API has to be completely
* independent on the current probing status
*/
@@ -444,9 +437,6 @@ void blkid_reset_probe(blkid_probe pr)
{
int i;
- if (!pr)
- return;
-
blkid_probe_reset_values(pr);
blkid_probe_set_wiper(pr, 0, 0);
@@ -490,7 +480,7 @@ unsigned long *blkid_probe_get_filter(blkid_probe pr, int chain, int create)
{
struct blkid_chain *chn;
- if (!pr || chain < 0 || chain >= BLKID_NCHAINS)
+ if (chain < 0 || chain >= BLKID_NCHAINS)
return NULL;
chn = &pr->chains[chain];
@@ -521,9 +511,6 @@ int __blkid_probe_invert_filter(blkid_probe pr, int chain)
size_t i;
struct blkid_chain *chn;
- if (!pr)
- return -1;
-
chn = &pr->chains[chain];
if (!chn->driver->has_fltr || !chn->fltr)
@@ -700,7 +687,7 @@ static void blkid_probe_reset_buffer(blkid_probe pr)
{
uint64_t ct = 0, len = 0;
- if (!pr || list_empty(&pr->buffers))
+ if (list_empty(&pr->buffers))
return;
DBG(BUFFER, ul_debug("Resetting probing buffers pr=%p", pr));
@@ -725,7 +712,7 @@ static void blkid_probe_reset_buffer(blkid_probe pr)
static void blkid_probe_reset_values(blkid_probe pr)
{
- if (!pr || list_empty(&pr->values))
+ if (list_empty(&pr->values))
return;
DBG(LOWPROBE, ul_debug("resetting results pr=%p", pr));
@@ -744,7 +731,7 @@ static void blkid_probe_reset_values(blkid_probe pr)
*/
int blkid_probe_is_tiny(blkid_probe pr)
{
- return pr && (pr->flags & BLKID_FL_TINY_DEV);
+ return (pr->flags & BLKID_FL_TINY_DEV);
}
/*
@@ -752,7 +739,7 @@ int blkid_probe_is_tiny(blkid_probe pr)
*/
int blkid_probe_is_cdrom(blkid_probe pr)
{
- return pr && (pr->flags & BLKID_FL_CDROM_DEV);
+ return (pr->flags & BLKID_FL_CDROM_DEV);
}
static int is_sector_readable(int fd, uint64_t sector)
@@ -818,9 +805,6 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
struct stat sb;
uint64_t devsiz = 0;
- if (!pr)
- return -1;
-
blkid_reset_probe(pr);
blkid_probe_reset_buffer(pr);
@@ -914,9 +898,6 @@ err:
int blkid_probe_get_dimension(blkid_probe pr, uint64_t *off, uint64_t *size)
{
- if (!pr)
- return -1;
-
*off = pr->off;
*size = pr->size;
return 0;
@@ -924,9 +905,6 @@ int blkid_probe_get_dimension(blkid_probe pr, uint64_t *off, uint64_t *size)
int blkid_probe_set_dimension(blkid_probe pr, uint64_t off, uint64_t size)
{
- if (!pr)
- return -1;
-
DBG(LOWPROBE, ul_debug(
"changing probing area pr=%p: size=%"PRIu64", off=%"PRIu64" "
"-to-> size=%"PRIu64", off=%"PRIu64"",
@@ -993,22 +971,18 @@ int blkid_probe_get_idmag(blkid_probe pr, const struct blkid_idinfo *id,
static inline void blkid_probe_start(blkid_probe pr)
{
- if (pr) {
- DBG(LOWPROBE, ul_debug("%p: start probe", pr));
- pr->cur_chain = NULL;
- pr->prob_flags = 0;
- blkid_probe_set_wiper(pr, 0, 0);
- }
+ DBG(LOWPROBE, ul_debug("%p: start probe", pr));
+ pr->cur_chain = NULL;
+ pr->prob_flags = 0;
+ blkid_probe_set_wiper(pr, 0, 0);
}
static inline void blkid_probe_end(blkid_probe pr)
{
- if (pr) {
- DBG(LOWPROBE, ul_debug("%p: end probe", pr));
- pr->cur_chain = NULL;
- pr->prob_flags = 0;
- blkid_probe_set_wiper(pr, 0, 0);
- }
+ DBG(LOWPROBE, ul_debug("%p: end probe", pr));
+ pr->cur_chain = NULL;
+ pr->prob_flags = 0;
+ blkid_probe_set_wiper(pr, 0, 0);
}
/**
@@ -1054,9 +1028,6 @@ int blkid_do_probe(blkid_probe pr)
{
int rc = 1;
- if (!pr)
- return -1;
-
if (pr->flags & BLKID_FL_NOSCAN_DEV)
return 1;
@@ -1147,9 +1118,6 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
int fd, rc = 0;
struct blkid_chain *chn;
- if (!pr)
- return -1;
-
chn = pr->cur_chain;
if (!chn)
return -1;
@@ -1253,9 +1221,6 @@ int blkid_probe_step_back(blkid_probe pr)
{
struct blkid_chain *chn;
- if (!pr)
- return -1;
-
chn = pr->cur_chain;
if (!chn)
return -1;
@@ -1309,8 +1274,6 @@ int blkid_do_safeprobe(blkid_probe pr)
{
int i, count = 0, rc = 0;
- if (!pr)
- return -1;
if (pr->flags & BLKID_FL_NOSCAN_DEV)
return 1;
@@ -1365,8 +1328,6 @@ int blkid_do_fullprobe(blkid_probe pr)
{
int i, count = 0, rc = 0;
- if (!pr)
- return -1;
if (pr->flags & BLKID_FL_NOSCAN_DEV)
return 1;
@@ -1408,16 +1369,12 @@ done:
/* same sa blkid_probe_get_buffer() but works with 512-sectors */
unsigned char *blkid_probe_get_sector(blkid_probe pr, unsigned int sector)
{
- return pr ? blkid_probe_get_buffer(pr,
- ((uint64_t) sector) << 9, 0x200) : NULL;
+ return blkid_probe_get_buffer(pr, ((uint64_t) sector) << 9, 0x200);
}
-struct blkid_prval *blkid_probe_assign_value(
- blkid_probe pr, const char *name)
+struct blkid_prval *blkid_probe_assign_value(blkid_probe pr, const char *name)
{
struct blkid_prval *v;
- if (!name)
- return NULL;
v = blkid_probe_new_value();
if (!v)
@@ -1510,7 +1467,7 @@ int blkid_probe_set_magic(blkid_probe pr, uint64_t offset,
int rc = 0;
struct blkid_chain *chn = blkid_probe_get_chain(pr);
- if (!chn || !magic || !len || chn->binary)
+ if (!chn || !len || chn->binary)
return 0;
switch (chn->driver->id) {
@@ -1666,7 +1623,7 @@ blkid_probe blkid_probe_get_wholedisk_probe(blkid_probe pr)
*/
blkid_loff_t blkid_probe_get_size(blkid_probe pr)
{
- return pr ? (blkid_loff_t) pr->size : -1;
+ return (blkid_loff_t) pr->size;
}
/**
@@ -1679,7 +1636,7 @@ blkid_loff_t blkid_probe_get_size(blkid_probe pr)
*/
blkid_loff_t blkid_probe_get_offset(blkid_probe pr)
{
- return pr ? (blkid_loff_t) pr->off : -1;
+ return (blkid_loff_t) pr->off;
}
/**
@@ -1690,7 +1647,7 @@ blkid_loff_t blkid_probe_get_offset(blkid_probe pr)
*/
int blkid_probe_get_fd(blkid_probe pr)
{
- return pr ? pr->fd : -1;
+ return pr->fd;
}
/**
@@ -1701,9 +1658,6 @@ int blkid_probe_get_fd(blkid_probe pr)
*/
unsigned int blkid_probe_get_sectorsize(blkid_probe pr)
{
- if (!pr)
- return DEFAULT_SECTOR_SIZE; /*... and good luck! */
-
if (pr->blkssz)
return pr->blkssz;
@@ -1723,7 +1677,7 @@ unsigned int blkid_probe_get_sectorsize(blkid_probe pr)
*/
blkid_loff_t blkid_probe_get_sectors(blkid_probe pr)
{
- return pr ? (blkid_loff_t) (pr->size >> 9) : -1;
+ return (blkid_loff_t) (pr->size >> 9);
}
/**
@@ -1736,8 +1690,6 @@ int blkid_probe_numof_values(blkid_probe pr)
{
int i = 0;
struct list_head *p;
- if (!pr)
- return -1;
list_for_each(p, &pr->values)
++i;
@@ -1817,7 +1769,7 @@ int blkid_probe_has_value(blkid_probe pr, const char *name)
struct blkid_prval *blkid_probe_last_value(blkid_probe pr)
{
- if (!pr || list_empty(&pr->values))
+ if (list_empty(&pr->values))
return NULL;
return list_last_entry(&pr->values, struct blkid_prval, prvals);
@@ -1829,7 +1781,7 @@ struct blkid_prval *__blkid_probe_get_value(blkid_probe pr, int num)
int i = 0;
struct list_head *p;
- if (!pr || num < 0)
+ if (num < 0)
return NULL;
list_for_each(p, &pr->values) {
@@ -1844,7 +1796,7 @@ struct blkid_prval *__blkid_probe_lookup_value(blkid_probe pr, const char *name)
{
struct list_head *p;
- if (!pr || list_empty(&pr->values) || !name)
+ if (list_empty(&pr->values))
return NULL;
list_for_each(p, &pr->values) {
@@ -1942,9 +1894,6 @@ void blkid_probe_set_wiper(blkid_probe pr, uint64_t off, uint64_t size)
{
struct blkid_chain *chn;
- if (!pr)
- return;
-
if (!size) {
DBG(LOWPROBE, ul_debug("zeroize wiper"));
pr->wipe_size = pr->wipe_off = 0;
@@ -1975,12 +1924,11 @@ void blkid_probe_set_wiper(blkid_probe pr, uint64_t off, uint64_t size)
*/
int blkid_probe_is_wiped(blkid_probe pr, struct blkid_chain **chn, uint64_t off, uint64_t size)
{
- if (!pr || !size)
+ if (!size)
return 0;
if (pr->wipe_off <= off && off + size <= pr->wipe_off + pr->wipe_size) {
- if (chn)
- *chn = pr->wipe_chain;
+ *chn = pr->wipe_chain;
return 1;
}
return 0;
diff --git a/libblkid/src/read.c b/libblkid/src/read.c
index b7afe2cd2..c081baff5 100644
--- a/libblkid/src/read.c
+++ b/libblkid/src/read.c
@@ -395,9 +395,6 @@ void blkid_read_cache(blkid_cache cache)
int fd, lineno = 0;
struct stat st;
- if (!cache)
- return;
-
/*
* If the file doesn't exist, then we just return an empty
* struct so that the cache can be populated.
diff --git a/libblkid/src/save.c b/libblkid/src/save.c
index 307053094..21308a9cf 100644
--- a/libblkid/src/save.c
+++ b/libblkid/src/save.c
@@ -86,9 +86,6 @@ int blkid_flush_cache(blkid_cache cache)
int fd, ret = 0;
struct stat st;
- if (!cache)
- return -BLKID_ERR_PARAM;
-
if (list_empty(&cache->bic_devs) ||
!(cache->bic_flags & BLKID_BIC_FL_CHANGED)) {
DBG(SAVE, ul_debug("skipping cache file write"));
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 4aeebf32e..341cd8a6f 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -185,8 +185,6 @@ const struct blkid_chaindrv superblocks_drv = {
*/
int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
{
- if (!pr)
- return -1;
pr->chains[BLKID_CHAIN_SUBLKS].enabled = enable;
return 0;
}
@@ -203,9 +201,6 @@ int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
*/
int blkid_probe_set_superblocks_flags(blkid_probe pr, int flags)
{
- if (!pr)
- return -1;
-
pr->chains[BLKID_CHAIN_SUBLKS].flags = flags;
return 0;
}
@@ -300,9 +295,6 @@ int blkid_known_fstype(const char *fstype)
{
size_t i;
- if (!fstype)
- return 0;
-
for (i = 0; i < ARRAY_SIZE(idinfos); i++) {
const struct blkid_idinfo *id = idinfos[i];
if (strcmp(id->name, fstype) == 0)
@@ -339,7 +331,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
size_t i;
int rc = BLKID_PROBE_NONE;
- if (!pr || chn->idx < -1)
+ if (chn->idx < -1)
return -EINVAL;
blkid_probe_chain_reset_values(pr, chn);
diff --git a/libblkid/src/tag.c b/libblkid/src/tag.c
index 2c0aa9b64..9b131ae47 100644
--- a/libblkid/src/tag.c
+++ b/libblkid/src/tag.c
@@ -55,9 +55,6 @@ blkid_tag blkid_find_tag_dev(blkid_dev dev, const char *type)
{
struct list_head *p;
- if (!dev || !type)
- return NULL;
-
list_for_each(p, &dev->bid_tags) {
blkid_tag tmp = list_entry(p, struct blkid_struct_tag,
bit_tags);
@@ -116,9 +113,6 @@ int blkid_set_tag(blkid_dev dev, const char *name,
char *val = 0;
char **dev_var = 0;
- if (!dev || !name)
- return -BLKID_ERR_PARAM;
-
if (value && !(val = strndup(value, vlength)))
return -BLKID_ERR_MEM;
diff --git a/libblkid/src/topology/topology.c b/libblkid/src/topology/topology.c
index 105f386c9..38e4c950d 100644
--- a/libblkid/src/topology/topology.c
+++ b/libblkid/src/topology/topology.c
@@ -110,8 +110,6 @@ const struct blkid_chaindrv topology_drv = {
*/
int blkid_probe_enable_topology(blkid_probe pr, int enable)
{
- if (!pr)
- return -1;
pr->chains[BLKID_CHAIN_TOPLGY].enabled = enable;
return 0;
}
@@ -146,7 +144,7 @@ static int topology_probe(blkid_probe pr, struct blkid_chain *chn)
{
size_t i;
- if (!pr || chn->idx < -1)
+ if (chn->idx < -1)
return -1;
if (!S_ISBLK(pr->mode))