]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Better dealing with attr = NULL bug.
authorDario Faggioli <faggioli@gandalf.sssup.it>
Fri, 27 Feb 2009 00:50:24 +0000 (01:50 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 1 Mar 2009 19:12:02 +0000 (20:12 +0100)
Differently cope with the possibility of the thread attributes being
NULL during thread_create_and_bind. This new solution initializes it
internally, thus avoiding a potential non-initialized used of variable
p, containing thread priority.

resources/cpucg/lib/frsh_cpucg.c

index 0ff04742f60d5a676aadc3883aa0bab1b94a8614..c7efd5b137bb0b4c8d9c029375ba7cd803d624e1 100644 (file)
@@ -305,11 +305,12 @@ int frsh_thread_create_and_bind(const frsh_vres_id_t vres,
        wp.vres = vres;
        wp.stopper = &stopper;
 
-       if (attr) {
-               pthread_attr_getschedparam(attr, &param);
-               p = param.sched_priority;
-               printf("priority = %d\n", p);
-       }
+       if (!attr)
+               pthread_attr_init(attr);
+
+       pthread_attr_getschedparam(attr, &param);
+       p = param.sched_priority;
+       printf("priority = %d\n", p);
        if (p == 0) {
                param.sched_priority = 1;
                pthread_attr_setschedparam(attr, &param);