udev-builtin: add a couple of asserts
This commit is contained in:
@@ -22,6 +22,9 @@
|
|||||||
static void set_usb_iftype(char *to, int if_class_num, size_t len) {
|
static void set_usb_iftype(char *to, int if_class_num, size_t len) {
|
||||||
const char *type = "generic";
|
const char *type = "generic";
|
||||||
|
|
||||||
|
assert(to);
|
||||||
|
assert(len > 0);
|
||||||
|
|
||||||
switch (if_class_num) {
|
switch (if_class_num) {
|
||||||
case 1:
|
case 1:
|
||||||
type = "audio";
|
type = "audio";
|
||||||
@@ -71,6 +74,8 @@ static int set_usb_mass_storage_ifsubtype(char *to, const char *from, size_t len
|
|||||||
int type_num = 0;
|
int type_num = 0;
|
||||||
const char *type = "generic";
|
const char *type = "generic";
|
||||||
|
|
||||||
|
assert(to);
|
||||||
|
|
||||||
if (safe_atoi(from, &type_num) >= 0)
|
if (safe_atoi(from, &type_num) >= 0)
|
||||||
switch (type_num) {
|
switch (type_num) {
|
||||||
case 1: /* RBC devices */
|
case 1: /* RBC devices */
|
||||||
@@ -98,6 +103,8 @@ static void set_scsi_type(char *to, const char *from, size_t len) {
|
|||||||
unsigned type_num;
|
unsigned type_num;
|
||||||
const char *type = "generic";
|
const char *type = "generic";
|
||||||
|
|
||||||
|
assert(to);
|
||||||
|
|
||||||
if (safe_atou(from, &type_num) >= 0)
|
if (safe_atou(from, &type_num) >= 0)
|
||||||
switch (type_num) {
|
switch (type_num) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -143,6 +150,10 @@ static int dev_if_packed_info(sd_device *dev, char *ifs_str, size_t len) {
|
|||||||
uint8_t iInterface;
|
uint8_t iInterface;
|
||||||
} _packed_;
|
} _packed_;
|
||||||
|
|
||||||
|
assert(dev);
|
||||||
|
assert(ifs_str);
|
||||||
|
assert(len >= 2);
|
||||||
|
|
||||||
r = sd_device_get_syspath(dev, &syspath);
|
r = sd_device_get_syspath(dev, &syspath);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
Reference in New Issue
Block a user