projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
31e21fb
)
src/plugin.c: Improve error messages in plugin_load().
author
Florian Forster
<octo@collectd.org>
Mon, 21 Jan 2013 10:36:48 +0000
(11:36 +0100)
committer
Florian Forster
<octo@collectd.org>
Mon, 21 Jan 2013 10:36:50 +0000
(11:36 +0100)
Fixes Github issue #237.
src/plugin.c
patch
|
blob
|
history
diff --git
a/src/plugin.c
b/src/plugin.c
index
547b5eb
..
478ec52
100644
(file)
--- a/
src/plugin.c
+++ b/
src/plugin.c
@@
-826,8
+826,6
@@
int plugin_load (const char *type, uint32_t flags)
struct dirent *de;
int status;
struct dirent *de;
int status;
- DEBUG ("type = %s", type);
-
dir = plugin_get_dir ();
ret = 1;
dir = plugin_get_dir ();
ret = 1;
@@
-836,7
+834,7
@@
int plugin_load (const char *type, uint32_t flags)
status = ssnprintf (typename, sizeof (typename), "%s.so", type);
if ((status < 0) || ((size_t) status >= sizeof (typename)))
{
status = ssnprintf (typename, sizeof (typename), "%s.so", type);
if ((status < 0) || ((size_t) status >= sizeof (typename)))
{
- WARNING ("
snprintf: truncated: `%s.so'
", type);
+ WARNING ("
plugin_load: Filename too long: \"%s.so\"
", type);
return (-1);
}
typename_len = strlen (typename);
return (-1);
}
typename_len = strlen (typename);
@@
-844,7
+842,7
@@
int plugin_load (const char *type, uint32_t flags)
if ((dh = opendir (dir)) == NULL)
{
char errbuf[1024];
if ((dh = opendir (dir)) == NULL)
{
char errbuf[1024];
- ERROR ("
opendir (%s)
: %s", dir,
+ ERROR ("
plugin_load: opendir (%s) failed
: %s", dir,
sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
@@
-858,25
+856,29
@@
int plugin_load (const char *type, uint32_t flags)
"%s/%s", dir, de->d_name);
if ((status < 0) || ((size_t) status >= sizeof (filename)))
{
"%s/%s", dir, de->d_name);
if ((status < 0) || ((size_t) status >= sizeof (filename)))
{
- WARNING ("snprintf: truncated: `%s/%s'", dir, de->d_name);
+ WARNING ("plugin_load: Filename too long: \"%s/%s\"",
+ dir, de->d_name);
continue;
}
if (lstat (filename, &statbuf) == -1)
{
char errbuf[1024];
continue;
}
if (lstat (filename, &statbuf) == -1)
{
char errbuf[1024];
- WARNING ("stat %s: %s", filename,
+ WARNING ("plugin_load: stat (\"%s\") failed: %s",
+ filename,
sstrerror (errno, errbuf, sizeof (errbuf)));
continue;
}
else if (!S_ISREG (statbuf.st_mode))
{
/* don't follow symlinks */
sstrerror (errno, errbuf, sizeof (errbuf)));
continue;
}
else if (!S_ISREG (statbuf.st_mode))
{
/* don't follow symlinks */
- WARNING ("stat %s: not a regular file", filename);
+ WARNING ("plugin_load: %s is not a regular file.",
+ filename);
continue;
}
continue;
}
- if (plugin_load_file (filename, flags) == 0)
+ status = plugin_load_file (filename, flags);
+ if (status == 0)
{
/* success */
ret = 0;
{
/* success */
ret = 0;
@@
-884,14
+886,16
@@
int plugin_load (const char *type, uint32_t flags)
}
else
{
}
else
{
- fprintf (stderr, "Unable to load plugin %s.\n", type);
+ ERROR ("plugin_load: Load plugin \"%s\" failed with "
+ "status %i.", type, status);
}
}
closedir (dh);
}
}
closedir (dh);
- if (filename[0] == '\0')
- fprintf (stderr, "Could not find plugin %s.\n", type);
+ if (filename[0] == 0)
+ ERROR ("plugin_load: Could not find plugin \"%s\" in %s",
+ type, dir);
return (ret);
}
return (ret);
}