ObjFW  Check-in [90f2f05c2c]

Overview
Comment:threading: Prevent possible division by zero
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 90f2f05c2c6444f5657dbf34a109ca323cd5ce17583826796bda54836afc9878
User & Date: js on 2014-07-23 23:09:25
Other Links: manifest | tags
Context
2014-07-23
23:23
OFTimer: Reschedule before executing the callback check-in: 7fa1dc3f95 user: js tags: trunk
23:09
threading: Prevent possible division by zero check-in: 90f2f05c2c user: js tags: trunk
19:34
threading: Get rid of warnings with old compilers check-in: 9e60532254 user: js tags: trunk
Changes

Modified src/threading_pthread.m from [cdf397d0df] to [7ca1a9fd57].

31
32
33
34
35
36
37


38
39


40
41
42
43
44
45
46

		minPrio = sched_get_priority_min(policy);
		maxPrio = sched_get_priority_max(policy);

		if (pthread_attr_getschedparam(&pattr, &param) != 0)
			return false;



		attr->priority = (float)(param.sched_priority - minPrio) /
		    (maxPrio - minPrio);



		if (pthread_attr_getstacksize(&pattr, &attr->stackSize) != 0)
			return false;
	} @finally {
		pthread_attr_destroy(&pattr);
	}








>
>
|
|
>
>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

		minPrio = sched_get_priority_min(policy);
		maxPrio = sched_get_priority_max(policy);

		if (pthread_attr_getschedparam(&pattr, &param) != 0)
			return false;

		/* Prevent possible division by zero */
		if (minPrio != maxPrio)
			attr->priority = (float)(param.sched_priority -
			    minPrio) / (maxPrio - minPrio);
		else
			attr->priority = 0;

		if (pthread_attr_getstacksize(&pattr, &attr->stackSize) != 0)
			return false;
	} @finally {
		pthread_attr_destroy(&pattr);
	}