commit 3c29341b5d4937ebdd1af08c9dc1dbd9169a6200 from: Florian Obser date: Thu Jul 21 05:40:38 2022 UTC path_got is unused and never assigned, no need to free it OK stsp commit - 538b6881e138e4c1312a50dd16acec14fb6af7bc commit + 3c29341b5d4937ebdd1af08c9dc1dbd9169a6200 blob - 46a800f76b25f65ad5bab982804a1d510abb2792 blob + cc19332e99847eb9da2ce2e427552b4b000d5413 --- lib/worktree.c +++ lib/worktree.c @@ -1256,13 +1256,12 @@ install_symlink(int *is_bad_symlink, struct got_worktr const struct got_error *err = NULL; char target_path[PATH_MAX]; size_t len, target_len = 0; - char *path_got = NULL; const uint8_t *buf = got_object_blob_get_read_buf(blob); size_t hdrlen = got_object_blob_get_hdrlen(blob); *is_bad_symlink = 0; - /* + /* * Blob object content specifies the target path of the link. * If a symbolic link cannot be installed we instead create * a regular file which contains the link target path stored @@ -1305,7 +1304,7 @@ install_symlink(int *is_bad_symlink, struct got_worktr GOT_DEFAULT_FILE_MODE, GOT_DEFAULT_FILE_MODE, blob, restoring_missing_file, reverting_versioned_file, 1, path_is_unversioned, repo, progress_cb, progress_arg); - goto done; + return err; } if (symlink(target_path, ondisk_path) == -1) { @@ -1314,12 +1313,12 @@ install_symlink(int *is_bad_symlink, struct got_worktr if (path_is_unversioned) { err = (*progress_cb)(progress_arg, GOT_STATUS_UNVERSIONED, path); - goto done; + return err; } err = replace_existing_symlink(&symlink_replaced, ondisk_path, target_path, target_len); if (err) - goto done; + return err; if (progress_cb) { if (symlink_replaced) { err = (*progress_cb)(progress_arg, @@ -1331,25 +1330,25 @@ install_symlink(int *is_bad_symlink, struct got_worktr GOT_STATUS_EXISTS, path); } } - goto done; /* Nothing else to do. */ + return err; /* Nothing else to do. */ } if (errno == ENOENT) { char *parent; err = got_path_dirname(&parent, ondisk_path); if (err) - goto done; + return err; err = add_dir_on_disk(worktree, parent); free(parent); if (err) - goto done; + return err; /* * Retry, and fall through to error handling * below if this second attempt fails. */ if (symlink(target_path, ondisk_path) != -1) { err = NULL; /* success */ - goto done; + return err; } } @@ -1373,8 +1372,6 @@ install_symlink(int *is_bad_symlink, struct got_worktr } else if (progress_cb) err = (*progress_cb)(progress_arg, reverting_versioned_file ? GOT_STATUS_REVERT : GOT_STATUS_ADD, path); -done: - free(path_got); return err; }