git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] gc: remove unused launchctl_get_uid() call

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Sep 12, 2021, 00:24 UTC
Message-ID
<patch-v2-1.1-794e68e7722-20210912T002334Z-avarab@gmail.com>
In-Reply-To
<87bl52dkv1.fsf@evledraar.gmail.com>

When the launchctl_boot_plist() function was added in a16eb6b1ff3 (maintenance: skip bootout/bootstrap when plist is registered, 2021-08-24), an unused call to launchctl_get_uid() was added along with it. That call appears to have been copy/pasted from launchctl_boot_plist().

Since we can remove that, we can also get rid of the "result" variable, whose only purpose was allow for the free() between its assignment and the return. That pattern also appears to have been copy/pasted from launchctl_boot_plist().

As the patch shows the returned value from launchctl_get_uid() wasn't used at all in this function. The launchctl_get_uid() function itself just calls xstrfmt() and getuid(), neither of which have any subtle global side-effects, so this removal is safe.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

Addresses a comment about the clarity of the commit message in v1: https://lore.kernel.org/git/87bl52dkv1.fsf@evledraar.gmail.com/

Range-diff against v1:
1:  93adb856b0c ! 1:  794e68e7722 gc: remove unused launchctl_get_uid() call
    @@ Commit message
         assignment and the return. That pattern also appears to have been
         copy/pasted from launchctl_boot_plist().
     
    +    As the patch shows the returned value from launchctl_get_uid() wasn't
    +    used at all in this function. The launchctl_get_uid() function itself
    +    just calls xstrfmt() and getuid(), neither of which have any subtle
    +    global side-effects, so this removal is safe.
    +
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
      ## builtin/gc.c ##
 builtin/gc.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index 43c36024cbe..db76af4f31c 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -1602,9 +1602,7 @@ static int launchctl_remove_plists(const char *cmd)
 
 static int launchctl_list_contains_plist(const char *name, const char *cmd)
 {
-	int result;
 	struct child_process child = CHILD_PROCESS_INIT;
-	char *uid = launchctl_get_uid();
 
 	strvec_split(&child.args, cmd);
 	strvec_pushl(&child.args, "list", name, NULL);
@@ -1615,12 +1613,8 @@ static int launchctl_list_contains_plist(const char *name, const char *cmd)
 	if (start_command(&child))
 		die(_("failed to start launchctl"));
 
-	result = finish_command(&child);
-
-	free(uid);
-
 	/* Returns failure if 'name' doesn't exist. */
-	return !result;
+	return !finish_command(&child);
 }
 
 static int launchctl_schedule_plist(const char *exec_path, enum schedule_priority schedule, const char *cmd)
-- 
2.33.0.998.ga4d44345d43
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 11 in “macos: safeguard git maintenance against highly concurrent operations”
  1. 0/2 macos: safeguard git maintenance against highly concurrent operationsJohannes Schindelin via GitGitGadget, Aug 24, 2021
  2. 1/2 maintenance: create `launchctl` configuration using a lock fileJohannes Schindelin via GitGitGadget, Aug 24, 2021
  3. 2/2 maintenance: skip bootout/bootstrap when plist is registeredDerrick Stolee via GitGitGadget, Aug 24, 2021
  4. gc: remove unused launchctl_get_uid() callÆvar Arnfjörð Bjarmason, Sep 9, 2021
  5. Johannes SchindelinSep 9, 2021
  6. Ævar Arnfjörð BjarmasonSep 9, 2021
  7. Johannes SchindelinSep 9, 2021
  8. Junio C HamanoSep 9, 2021
  9. gc: remove unused launchctl_get_uid() callÆvar Arnfjörð Bjarmason, Sep 12, 2021
  10. Junio C HamanoAug 25, 2021
  11. Johannes SchindelinAug 25, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.