Il 29/12/23 15:01, Samuel Thibault ha scritto:
Luca Dariz, le jeu. 28 déc. 2023 20:42:52 +0100, a ecrit:
+  mach_port_t newname = 123;

Why initializing it?

the idea was to check that the value it's actually set, I'll fix it by using a valid port name.


+  err = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, 
&newname);
+  ASSERT_RET(err, "mach_port_allocate");
+  err = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, 
&newname);
+  ASSERT_RET(err, "mach_port_allocate");
+  err = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_DEAD_NAME, 
&newname);
+  ASSERT_RET(err, "mach_port_allocate");

You could check that you are getting different names.

ok


+  err = mach_port_destroy(mach_task_self(), newname);
+  ASSERT_RET(err, "mach_port_destroy");
+
+  err = mach_port_deallocate(mach_task_self(), 1002);
+  ASSERT_RET(err, "mach_port_deallocate");
+
+  mach_port_urefs_t urefs;
+  err = mach_port_get_refs(mach_task_self(), 1002, MACH_PORT_RIGHT_DEAD_NAME, 
&urefs);
+  ASSERT_RET(err, "mach_port_get_refs");

You could also check the references of the ports created above.

ok


Luca


Reply via email to