Skip to contentSkip to conversation

lib/cobalt: remove unused `pthread_attr_getdetachstate`

PATCH Applied Qichen Qiu 3 participants 5 messages Dec 9, 2024 – Dec 10, 2024

lore
Share & tools
lore

Qichen Qiu

author
#0 lore raw

PATCH 1/1 lib/cobalt: remove unused `pthread_attr_getdetachstate`

The detachstate is used to determine if it is PTHREAD_CREATE_JOINABLE. Since this check has been removed, the retrieval of detachstate seems to be unused.

---
 lib/cobalt/thread.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
lib/cobalt/thread.c +1 -2
index dee39a8d4..e237e7ba1 100644
@@ -129,7 +129,7 @@ int pthread_create_ex(pthread_t *ptid_r,
 		      const pthread_attr_ex_t *attr_ex,
 		      void *(*start) (void *), void *arg)
 {
-	int inherit, detachstate, ret;
+	int inherit, ret;
 	struct pthread_iargs iargs;
 	struct sched_param param;
 	struct timespec timeout;
@@ -167,7 +167,6 @@ int pthread_create_ex(pthread_t *ptid_r,
 		 */
 		pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
 
-	pthread_attr_getdetachstate(&attr, &detachstate);
 	pthread_attr_getpersonality_ex(attr_ex, &iargs.personality);
 
 	/*
Signature · 1 line
2.34.1
#1 lore raw
Quoted 14 lines · Qichen Qiu

The detachstate is used to determine if it is PTHREAD_CREATE_JOINABLE. Since this check has been removed, the retrieval of detachstate seems to be unused.

---
 lib/cobalt/thread.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
lib/cobalt/thread.c +0 -0
index dee39a8d4..e237e7ba1 100644

lib/cobalt/thread.c int pthread_create_ex(pthread_t *ptid_r, · line 132

Quoted 5 lines
lib/cobalt/thread.c +1 -1
@@ -129,7 +129,7 @@ int pthread_create_ex(pthread_t *ptid_r,
 		      const pthread_attr_ex_t *attr_ex,
 		      void *(*start) (void *), void *arg)
 {
-	int inherit, detachstate, ret;
+	int inherit, ret;

Checkpatch reports a DOS line ending here. Please fix.

Quoted 14 lines
lib/cobalt/thread.c +0 -1
 	struct pthread_iargs iargs;
 	struct sched_param param;
 	struct timespec timeout;
@@ -167,7 +167,6 @@ int pthread_create_ex(pthread_t *ptid_r,
 		 */
 		pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
 
-	pthread_attr_getdetachstate(&attr, &detachstate);
 	pthread_attr_getpersonality_ex(attr_ex, &iargs.personality);
 
 	/*
Signature · 1 line
2.34.1
author
#2 lore raw

Hi Florian.

I apologize for not using the checkpatch tool initially. However, I have reviewed my patch again and did not find any DOS line endings. Here are the steps to reproduce my checks:

b4 am 20241209_ruiqurm_lib_cobalt_remove_unused_pthread_attr_getdetachstate.mbx ./scripts/checkpatch.pl 20241209_ruiqurm_lib_cobalt_remove_unused_pthread_attr_getdetachstate.mbx

The output is:
20241209_ruiqurm_lib_cobalt_remove_unused_pthread_attr_getdetachstate.mbx has no obvious style problems and is ready for submission.

Additionally, I used the hexdump tool to inspect the file for DOS line.
hexdump -C 20241209_ruiqurm_lib_cobalt_remove_unused_pthread_attr_getdetachstate.mbx | grep '0d 0a'

If there are additional steps or tools you would recommend for verifying this issue, please let me know.

#3 lore raw
Quoted 9 lines · Qichen Qiu

Hi Florian.

I apologize for not using the checkpatch tool initially. However, I have reviewed my patch again and did not find any DOS line endings. Here are the steps to reproduce my checks:

b4 am 20241209_ruiqurm_lib_cobalt_remove_unused_pthread_attr_getdetachstate.mbx ./scripts/checkpatch.pl 20241209_ruiqurm_lib_cobalt_remove_unused_pthread_attr_getdetachstate.mbx

Quoted 8 lines

The output is:
20241209_ruiqurm_lib_cobalt_remove_unused_pthread_attr_getdetachstate.mbx has no obvious style problems and is ready for submission.

Additionally, I used the hexdump tool to inspect the file for DOS line.
hexdump -C 20241209_ruiqurm_lib_cobalt_remove_unused_pthread_attr_getdetachstate.mbx | grep '0d 0a'

If there are additional steps or tools you would recommend for verifying this issue, please let me know.

That is/was a problem on my side. I ran the tool on the mbox instead of the plain patch. Local tooling bug. That one is fixed now. ;-)

Applied
#4 lore raw
In reply to Qichen Qiu
Quoted 23 lines · Qichen Qiu

The detachstate is used to determine if it is PTHREAD_CREATE_JOINABLE. Since this check has been removed, the retrieval of detachstate seems to be unused.

---
 lib/cobalt/thread.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
lib/cobalt/thread.c +1 -1
index dee39a8d4..e237e7ba1 100644
@@ -129,7 +129,7 @@ int pthread_create_ex(pthread_t *ptid_r,
 		      const pthread_attr_ex_t *attr_ex,
 		      void *(*start) (void *), void *arg)
 {
-	int inherit, detachstate, ret;
+	int inherit, ret;
 	struct pthread_iargs iargs;
 	struct sched_param param;
 	struct timespec timeout;

lib/cobalt/thread.c int pthread_create_ex(pthread_t *ptid_r, · line 172

Quoted 7 lines
lib/cobalt/thread.c +0 -1
@@ -167,7 +167,6 @@ int pthread_create_ex(pthread_t *ptid_r,
 		 */
 		pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
 
-	pthread_attr_getdetachstate(&attr, &detachstate);
 	pthread_attr_getpersonality_ex(attr_ex, &iargs.personality);
 
 	/*

Thanks, applied this cleanup for a 10 years old commit :)

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center