@@ -26,7 +26,7 @@
#include "checkers.h"
#include "../libmultipath/debug.h"
-#include "../libmultipath/uevent.h"
+#include "../libmultipath/util.h"
#include "../libmultipath/time-util.h"
struct rbd_checker_context;
@@ -19,7 +19,7 @@
#include "../libmultipath/debug.h"
#include "../libmultipath/sg_include.h"
-#include "../libmultipath/uevent.h"
+#include "../libmultipath/util.h"
#include "../libmultipath/time-util.h"
#include "../libmultipath/util.h"
@@ -37,7 +37,6 @@
#include <linux/types.h>
#include <linux/netlink.h>
#include <pthread.h>
-#include <limits.h>
#include <sys/mman.h>
#include <libudev.h>
#include <errno.h>
@@ -81,30 +80,6 @@ struct uevent * alloc_uevent (void)
}
void
-setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached)
-{
- if (pthread_attr_init(attr)) {
- fprintf(stderr, "can't initialize thread attr: %s\n",
- strerror(errno));
- exit(1);
- }
- if (stacksize < PTHREAD_STACK_MIN)
- stacksize = PTHREAD_STACK_MIN;
-
- if (pthread_attr_setstacksize(attr, stacksize)) {
- fprintf(stderr, "can't set thread stack size to %lu: %s\n",
- (unsigned long)stacksize, strerror(errno));
- exit(1);
- }
- if (detached && pthread_attr_setdetachstate(attr,
- PTHREAD_CREATE_DETACHED)) {
- fprintf(stderr, "can't set thread to detached: %s\n",
- strerror(errno));
- exit(1);
- }
-}
-
-void
service_uevq(struct list_head *tmpq)
{
struct uevent *uev, *tmp;
@@ -27,7 +27,6 @@ struct uevent {
};
int is_uevent_busy(void);
-void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached);
int uevent_listen(struct udev *udev);
int uevent_dispatch(int (*store_uev)(struct uevent *, void * trigger_data),
@@ -1,7 +1,10 @@
-#include <string.h>
+#include <assert.h>
#include <ctype.h>
-#include <sys/types.h>
+#include <limits.h>
+#include <pthread.h>
+#include <string.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include "debug.h"
@@ -258,3 +261,21 @@ dev_t parse_devt(const char *dev_t)
return makedev(maj, min);
}
+
+void
+setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached)
+{
+ int ret;
+
+ ret = pthread_attr_init(attr);
+ assert(ret == 0);
+ if (stacksize < PTHREAD_STACK_MIN)
+ stacksize = PTHREAD_STACK_MIN;
+ ret = pthread_attr_setstacksize(attr, stacksize);
+ assert(ret == 0);
+ if (detached) {
+ ret = pthread_attr_setdetachstate(attr,
+ PTHREAD_CREATE_DETACHED);
+ assert(ret == 0);
+ }
+}
@@ -12,6 +12,7 @@ size_t strlcat(char *dst, const char *src, size_t size);
int devt2devname (char *, int, char *);
dev_t parse_devt(const char *dev_t);
char *convert_dev(char *dev, int is_path_device);
+void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached);
#define safe_sprintf(var, format, args...) \
snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
The setup_thread_attr() is not called by any code in source file uevent.c. Hence move that function to source file util.c. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> --- libmultipath/checkers/rbd.c | 2 +- libmultipath/checkers/tur.c | 2 +- libmultipath/uevent.c | 25 ------------------------- libmultipath/uevent.h | 1 - libmultipath/util.c | 25 +++++++++++++++++++++++-- libmultipath/util.h | 1 + 6 files changed, 26 insertions(+), 30 deletions(-)