From a748ceffe8db5919e020fe6537ee79e542d762a4 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sun, 12 Jun 2005 15:00:52 +0000 Subject: check for list errors creating list of camlibs and abort in case of errors git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@8082 67ed7778-7388-44ab-90cf-0a291f65f57c --- libgphoto2/gphoto2-abilities-list.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'libgphoto2/gphoto2-abilities-list.c') diff --git a/libgphoto2/gphoto2-abilities-list.c b/libgphoto2/gphoto2-abilities-list.c index 86d526d9c..fc6da8531 100644 --- a/libgphoto2/gphoto2-abilities-list.c +++ b/libgphoto2/gphoto2-abilities-list.c @@ -131,12 +131,13 @@ static int foreach_func (const char *filename, lt_ptr data) { CameraList *list = data; + int result; gp_log (GP_LOG_DEBUG, "gphoto2-abilities-list", "Found '%s'.", filename); - gp_list_append (list, filename, NULL); + result = gp_list_append (list, filename, NULL); - return (0); + return ((result == GP_OK)?0:1); } @@ -152,6 +153,7 @@ gp_abilities_list_load_dir (CameraAbilitiesList *list, const char *dir, const char *filename; CameraList *flist; int count; + int ret; lt_dlhandle lh; CHECK_NULL (list && dir); @@ -162,8 +164,16 @@ gp_abilities_list_load_dir (CameraAbilitiesList *list, const char *dir, CHECK_RESULT (gp_list_reset (flist)); lt_dlinit (); lt_dladdsearchdir (dir); - lt_dlforeachfile (dir, foreach_func, flist); + ret = lt_dlforeachfile (dir, foreach_func, flist); lt_dlexit (); + if (ret != 0) { + gp_log (GP_LOG_ERROR, "gp-abilities-list", + "Internal error looking for camlibs (%d)", ret); + gp_context_error (context, + _("Internal error looking for camlibs. " + "(path names too long?)")); + return (GP_ERROR); + } CHECK_RESULT (count = gp_list_count (flist)); gp_log (GP_LOG_DEBUG, "gp-abilities-list", "Found %i " "camera drivers.", count); @@ -371,7 +381,7 @@ gp_abilities_list_detect (CameraAbilitiesList *list, CHECK_NULL (list && info_list && l); - l->count = 0; + gp_list_reset (l); CHECK_RESULT (info_count = gp_port_info_list_count (info_list)); -- cgit v1.2.1