mirror of
https://github.com/systemd/systemd.git
synced 2026-11-06 13:27:45 +00:00
storage: comment bare literal arguments
docs/CODING_STYLE.md asks for a /* name= */ comment whenever NULL or another value meaning "unset" is passed to a function. Add it wherever a bare NULL, 0, false or true is passed for a parameter with a telling name. Mechanical, generated by tools/check-argument-comments.py --fix.
This commit is contained in:
1 parent
bdde4ab58c
commit
74b3bd07fc
3 files changed
+22
-22
No files matched your search
@@ -206,7 +206,7 @@ static int vl_method_list_templates(
|
||||
assert(link);
|
||||
assert(FLAGS_SET(flags, SD_VARLINK_METHOD_MORE));
|
||||
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchTemplate", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchTemplate", /* parameters= */ NULL);
|
||||
}
|
||||
|
||||
static int device_open_disk_auto_rw(sd_device *d, int *read_only) {
|
||||
@@ -273,10 +273,10 @@ static int vl_method_acquire(
|
||||
if (!storage_volume_name_is_valid(p.name))
|
||||
return sd_varlink_error_invalid_parameter_name(link, "name");
|
||||
if (!path_startswith(p.name, "/dev") || !path_is_normalized(p.name))
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchVolume", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchVolume", /* parameters= */ NULL);
|
||||
|
||||
if (!IN_SET(p.create_mode, CREATE_ANY, CREATE_OPEN))
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.CreateNotSupported", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.CreateNotSupported", /* parameters= */ NULL);
|
||||
|
||||
/* off_t is signed, hence refuse overly long requests */
|
||||
if (p.create_size != UINT64_MAX && p.create_size > INT64_MAX)
|
||||
@@ -286,11 +286,11 @@ static int vl_method_acquire(
|
||||
if (!storage_template_name_is_valid(p.template))
|
||||
return sd_varlink_error_invalid_parameter_name(link, "template");
|
||||
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchTemplate", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchTemplate", /* parameters= */ NULL);
|
||||
}
|
||||
|
||||
if (p.request_as >= 0 && p.request_as != VOLUME_BLK)
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.TypeNotSupported", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.TypeNotSupported", /* parameters= */ NULL);
|
||||
|
||||
const char *details[] = {
|
||||
"name", p.name,
|
||||
@@ -309,12 +309,12 @@ static int vl_method_acquire(
|
||||
_cleanup_(sd_device_unrefp) sd_device *d = NULL;
|
||||
r = sd_device_new_from_devname(&d, p.name);
|
||||
if (ERRNO_IS_NEG_DEVICE_ABSENT(r))
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchVolume", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchVolume", /* parameters= */ NULL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!device_in_subsystem(d, "block"))
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchVolume", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchVolume", /* parameters= */ NULL);
|
||||
|
||||
/* The error returns are sometimes a bit inconclusive (i.e. read-only media might appear as
|
||||
* inaccessible due to a permission issue), hence let's do an explicit check first, to give good
|
||||
@@ -325,7 +325,7 @@ static int vl_method_acquire(
|
||||
log_device_debug_errno(d, r, "Failed to acquire read-only flag of device '%s', ignoring: %m", p.name);
|
||||
else if (r > 0) {
|
||||
if (p.read_only == 0)
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.ReadOnlyVolume", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.ReadOnlyVolume", /* parameters= */ NULL);
|
||||
|
||||
p.read_only = true;
|
||||
}
|
||||
@@ -333,7 +333,7 @@ static int vl_method_acquire(
|
||||
|
||||
_cleanup_close_ int fd = device_open_disk_auto_rw(d, &p.read_only);
|
||||
if (ERRNO_IS_NEG_FS_WRITE_REFUSED(fd))
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.ReadOnlyVolume", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.ReadOnlyVolume", /* parameters= */ NULL);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
|
||||
+12
-12
@@ -455,7 +455,7 @@ static int vl_method_acquire(
|
||||
return sd_varlink_error_invalid_parameter_name(link, "name");
|
||||
|
||||
if (!IN_SET(p.create_mode, CREATE_ANY, CREATE_OPEN, CREATE_NEW))
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.CreateNotSupported", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.CreateNotSupported", /* parameters= */ NULL);
|
||||
|
||||
/* off_t is signed, hence refuse overly long requests */
|
||||
if (p.create_size != UINT64_MAX && p.create_size > INT64_MAX)
|
||||
@@ -468,7 +468,7 @@ static int vl_method_acquire(
|
||||
|
||||
t = template_from_string(p.template);
|
||||
if (t < 0)
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchTemplate", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchTemplate", /* parameters= */ NULL);
|
||||
}
|
||||
|
||||
if (p.read_only > 0) {
|
||||
@@ -513,7 +513,7 @@ static int vl_method_acquire(
|
||||
if (r != -ENOENT)
|
||||
return r;
|
||||
if (p.create_mode == CREATE_OPEN || p.read_only > 0)
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchVolume", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.NoSuchVolume", /* parameters= */ NULL);
|
||||
|
||||
/* Doesn't exist yet: create it now */
|
||||
|
||||
@@ -534,7 +534,7 @@ static int vl_method_acquire(
|
||||
|
||||
case VOLUME_REG: {
|
||||
if (p.create_size == UINT64_MAX)
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.CreateSizeRequired", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.CreateSizeRequired", /* parameters= */ NULL);
|
||||
|
||||
if (t < 0) /* Make a choice: pick default template */
|
||||
t = TEMPLATE_SPARSE_FILE;
|
||||
@@ -546,17 +546,17 @@ static int vl_method_acquire(
|
||||
case VOLUME_BLK:
|
||||
/* We don't support creating block devices, we only support if they are symlinked
|
||||
* into the storage directory. */
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.CreateNotSupported", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.CreateNotSupported", /* parameters= */ NULL);
|
||||
|
||||
default:
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (real_fd == -ENOMEDIUM)
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.BadTemplate", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.BadTemplate", /* parameters= */ NULL);
|
||||
if (real_fd == -EEXIST) {
|
||||
if (p.create_mode == CREATE_NEW)
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.VolumeExists", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.VolumeExists", /* parameters= */ NULL);
|
||||
|
||||
/* If we failed to open the volume and reached this point, then the volume already
|
||||
* exists by now (i.e. we ran into a race). In that case, try to pin it a second time
|
||||
@@ -568,7 +568,7 @@ static int vl_method_acquire(
|
||||
return real_fd;
|
||||
|
||||
} else if (p.create_mode == CREATE_NEW)
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.VolumeExists", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.VolumeExists", /* parameters= */ NULL);
|
||||
|
||||
/* At this point, we either already opened the real fd, or we managed to pin it (but not both) */
|
||||
assert((real_fd >= 0) != (pin_fd >= 0));
|
||||
@@ -581,7 +581,7 @@ static int vl_method_acquire(
|
||||
if (p.request_as == VOLUME_REG) {
|
||||
/* First, check for the other supported types and generate a nice error */
|
||||
if (IN_SET(st.st_mode & S_IFMT, S_IFDIR, S_IFBLK))
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.WrongType", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.WrongType", /* parameters= */ NULL);
|
||||
|
||||
/* Second verify cover all other types */
|
||||
r = stat_verify_regular(&st);
|
||||
@@ -589,14 +589,14 @@ static int vl_method_acquire(
|
||||
return r;
|
||||
} else if (p.request_as == VOLUME_DIR) {
|
||||
if (IN_SET(st.st_mode & S_IFMT, S_IFREG, S_IFBLK))
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.WrongType", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.WrongType", /* parameters= */ NULL);
|
||||
|
||||
r = stat_verify_directory(&st);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else if (p.request_as == VOLUME_BLK) {
|
||||
if (IN_SET(st.st_mode & S_IFMT, S_IFREG, S_IFDIR))
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.WrongType", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.WrongType", /* parameters= */ NULL);
|
||||
|
||||
r = stat_verify_block(&st);
|
||||
if (r < 0)
|
||||
@@ -711,7 +711,7 @@ static int vl_method_acquire(
|
||||
}
|
||||
|
||||
if (p.read_only == 0 && ro)
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.ReadOnlyVolume", NULL);
|
||||
return sd_varlink_error(link, "io.systemd.StorageProvider.ReadOnlyVolume", /* parameters= */ NULL);
|
||||
|
||||
int idx = sd_varlink_push_fd(link, real_fd);
|
||||
if (idx < 0)
|
||||
|
||||
@@ -694,7 +694,7 @@ static int run_as_mount_helper(int argc, char *argv[]) {
|
||||
if (strv_extend_strv(&cmdline, STRV_MAKE(FORMAT_PROC_FD_PATH(reply.fd), path), /* filter_duplicates= */ false) < 0)
|
||||
return log_oom();
|
||||
|
||||
r = fd_cloexec(reply.fd, false);
|
||||
r = fd_cloexec(reply.fd, /* cloexec= */ false);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to disable O_CLOEXEC for mount fd: %m");
|
||||
|
||||
|
||||
Reference in new issue
Block a user