util: rework strappenda(), and rename it strjoina()
After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
This commit is contained in:
@@ -303,7 +303,7 @@ int curl_glue_make(CURL **ret, const char *url, void *userdata) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
useragent = strappenda(program_invocation_short_name, "/" PACKAGE_VERSION);
|
||||
useragent = strjoina(program_invocation_short_name, "/" PACKAGE_VERSION);
|
||||
if (curl_easy_setopt(c, CURLOPT_USERAGENT, useragent) != CURLE_OK) {
|
||||
r = -EIO;
|
||||
goto fail;
|
||||
|
||||
@@ -121,7 +121,7 @@ int import_make_local_copy(const char *final, const char *image_root, const char
|
||||
if (!image_root)
|
||||
image_root = "/var/lib/machines";
|
||||
|
||||
p = strappenda(image_root, "/", local);
|
||||
p = strjoina(image_root, "/", local);
|
||||
|
||||
if (force_local) {
|
||||
(void) btrfs_subvol_remove(p);
|
||||
@@ -309,7 +309,7 @@ int import_verify(
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
line = strappenda(main_job->checksum, " *", fn, "\n");
|
||||
line = strjoina(main_job->checksum, " *", fn, "\n");
|
||||
|
||||
p = memmem(checksum_job->payload,
|
||||
checksum_job->payload_size,
|
||||
|
||||
@@ -399,7 +399,7 @@ static int dkr_import_add_token(DkrImport *i, ImportJob *j) {
|
||||
assert(j);
|
||||
|
||||
if (i->response_token)
|
||||
t = strappenda("Authorization: Token ", i->response_token);
|
||||
t = strjoina("Authorization: Token ", i->response_token);
|
||||
else
|
||||
t = HEADER_TOKEN " true";
|
||||
|
||||
@@ -480,7 +480,7 @@ static int dkr_import_job_on_open_disk(ImportJob *j) {
|
||||
if (base) {
|
||||
const char *base_path;
|
||||
|
||||
base_path = strappenda(i->image_root, "/.dkr-", base);
|
||||
base_path = strjoina(i->image_root, "/.dkr-", base);
|
||||
r = btrfs_subvol_snapshot(base_path, i->temp_path, false, true);
|
||||
} else
|
||||
r = btrfs_subvol_make(i->temp_path);
|
||||
@@ -549,7 +549,7 @@ static int dkr_import_pull_layer(DkrImport *i) {
|
||||
i->final_path = path;
|
||||
path = NULL;
|
||||
|
||||
url = strappenda(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", layer, "/layer");
|
||||
url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", layer, "/layer");
|
||||
r = import_job_new(&i->layer_job, url, i->glue, i);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to allocate layer job: %m");
|
||||
@@ -610,7 +610,7 @@ static void dkr_import_job_on_finished(ImportJob *j) {
|
||||
log_info("Index lookup succeeded, directed to registry %s.", i->response_registries[0]);
|
||||
dkr_import_report_progress(i, DKR_RESOLVING);
|
||||
|
||||
url = strappenda(PROTOCOL_PREFIX, i->response_registries[0], "/v1/repositories/", i->name, "/tags/", i->tag);
|
||||
url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/repositories/", i->name, "/tags/", i->tag);
|
||||
r = import_job_new(&i->tags_job, url, i->glue, i);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to allocate tags job: %m");
|
||||
@@ -652,7 +652,7 @@ static void dkr_import_job_on_finished(ImportJob *j) {
|
||||
log_info("Tag lookup succeeded, resolved to layer %s.", i->id);
|
||||
dkr_import_report_progress(i, DKR_METADATA);
|
||||
|
||||
url = strappenda(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", i->id, "/ancestry");
|
||||
url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", i->id, "/ancestry");
|
||||
r = import_job_new(&i->ancestry_job, url, i->glue, i);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to allocate ancestry job: %m");
|
||||
@@ -668,7 +668,7 @@ static void dkr_import_job_on_finished(ImportJob *j) {
|
||||
i->ancestry_job->on_finished = dkr_import_job_on_finished;
|
||||
i->ancestry_job->on_progress = dkr_import_job_on_progress;
|
||||
|
||||
url = strappenda(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", i->id, "/json");
|
||||
url = strjoina(PROTOCOL_PREFIX, i->response_registries[0], "/v1/images/", i->id, "/json");
|
||||
r = import_job_new(&i->json_job, url, i->glue, i);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to allocate json job: %m");
|
||||
@@ -873,7 +873,7 @@ int dkr_import_pull(DkrImport *i, const char *name, const char *tag, const char
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
url = strappenda(i->index_url, "/v1/repositories/", name, "/images");
|
||||
url = strjoina(i->index_url, "/v1/repositories/", name, "/images");
|
||||
|
||||
r = import_job_new(&i->images_job, url, i->glue, i);
|
||||
if (r < 0)
|
||||
|
||||
@@ -270,7 +270,7 @@ static int raw_import_make_local_copy(RawImport *i) {
|
||||
return log_error_errno(errno, "Failed to seek to beginning of vendor image: %m");
|
||||
}
|
||||
|
||||
p = strappenda(i->image_root, "/", i->local, ".raw");
|
||||
p = strjoina(i->image_root, "/", i->local, ".raw");
|
||||
|
||||
if (i->force_local) {
|
||||
(void) btrfs_subvol_remove(p);
|
||||
|
||||
Reference in New Issue
Block a user