Removed excessive assertions in the device_list code -- it is ok to pass

a NULL list head (in which case you have an empty device list). All the
code works fine with a NULL head and returns appropriate values. Removed
changes to video_screen_count() and video_screen_first() which were added
to work around this behavior.
This commit is contained in:
Aaron Giles 2008-03-19 08:15:37 +00:00
parent 109441c041
commit 5807e98052
2 changed files with 2 additions and 14 deletions

View File

@ -183,7 +183,6 @@ int device_list_items(const device_config *listhead, device_type type)
const device_config *curdev; const device_config *curdev;
int count = 0; int count = 0;
assert(listhead != NULL);
assert(type != NULL); assert(type != NULL);
/* locate all devices */ /* locate all devices */
@ -204,7 +203,6 @@ const device_config *device_list_first(const device_config *listhead, device_typ
{ {
const device_config *curdev; const device_config *curdev;
assert(listhead != NULL);
assert(type != NULL); assert(type != NULL);
/* scan forward starting with the list head */ /* scan forward starting with the list head */
@ -247,7 +245,6 @@ const device_config *device_list_find_by_tag(const device_config *listhead, devi
{ {
const device_config *curdev; const device_config *curdev;
assert(listhead != NULL);
assert(type != NULL); assert(type != NULL);
assert(tag != NULL); assert(tag != NULL);
@ -272,7 +269,6 @@ int device_list_index(const device_config *listhead, device_type type, const cha
const device_config *curdev; const device_config *curdev;
int index = 0; int index = 0;
assert(listhead != NULL);
assert(type != NULL); assert(type != NULL);
assert(tag != NULL); assert(tag != NULL);
@ -298,7 +294,6 @@ const device_config *device_list_find_by_index(const device_config *listhead, de
{ {
const device_config *curdev; const device_config *curdev;
assert(listhead != NULL);
assert(type != NULL); assert(type != NULL);
assert(index >= 0); assert(index >= 0);
@ -327,8 +322,6 @@ int device_list_class_items(const device_config *listhead, device_class class)
const device_config *curdev; const device_config *curdev;
int count = 0; int count = 0;
assert(listhead != NULL);
/* locate all devices */ /* locate all devices */
for (curdev = listhead; curdev != NULL; curdev = curdev->next) for (curdev = listhead; curdev != NULL; curdev = curdev->next)
count += (curdev->class == class); count += (curdev->class == class);
@ -346,8 +339,6 @@ const device_config *device_list_class_first(const device_config *listhead, devi
{ {
const device_config *curdev; const device_config *curdev;
assert(listhead != NULL);
/* scan forward starting with the list head */ /* scan forward starting with the list head */
for (curdev = listhead; curdev != NULL; curdev = curdev->next) for (curdev = listhead; curdev != NULL; curdev = curdev->next)
if (curdev->class == class) if (curdev->class == class)
@ -386,7 +377,6 @@ const device_config *device_list_class_find_by_tag(const device_config *listhead
{ {
const device_config *curdev; const device_config *curdev;
assert(listhead != NULL);
assert(tag != NULL); assert(tag != NULL);
/* find the device in the list */ /* find the device in the list */
@ -409,7 +399,6 @@ int device_list_class_index(const device_config *listhead, device_class class, c
const device_config *curdev; const device_config *curdev;
int index = 0; int index = 0;
assert(listhead != NULL);
assert(tag != NULL); assert(tag != NULL);
/* locate all devices */ /* locate all devices */
@ -435,7 +424,6 @@ const device_config *device_list_class_find_by_index(const device_config *listhe
{ {
const device_config *curdev; const device_config *curdev;
assert(listhead != NULL);
assert(index >= 0); assert(index >= 0);
/* find the device in the list */ /* find the device in the list */

View File

@ -44,8 +44,8 @@ enum
/* these functions are macros primarily due to include file ordering */ /* these functions are macros primarily due to include file ordering */
/* plus, they are very simple */ /* plus, they are very simple */
#define video_screen_count(config) ((config)->devicelist ? device_list_items((config)->devicelist, VIDEO_SCREEN) : 0) #define video_screen_count(config) device_list_items((config)->devicelist, VIDEO_SCREEN)
#define video_screen_first(config) ((config)->devicelist ? device_list_first((config)->devicelist, VIDEO_SCREEN) : NULL) #define video_screen_first(config) device_list_first((config)->devicelist, VIDEO_SCREEN)
#define video_screen_next(previous) device_list_next((previous), VIDEO_SCREEN) #define video_screen_next(previous) device_list_next((previous), VIDEO_SCREEN)
#define video_screen_get_format(screen) (((screen_config *)(screen)->inline_config)->format) #define video_screen_get_format(screen) (((screen_config *)(screen)->inline_config)->format)