if (!devname)
snprintf(z->devname, sizeof(z->devname), "/dev/zram%zu", n);
- else {
- strncpy(z->devname, devname, sizeof(z->devname));
- z->devname[sizeof(z->devname) - 1] = '\0';
- }
+ else
+ xstrncpy(z->devname, devname, sizeof(z->devname));
DBG(fprintf(stderr, "set devname: %s", z->devname));
ul_unref_path(z->sysfs);
static int zram_control_add(struct zram *z)
{
- int n;
+ int n = 0;
struct path_cxt *ctl;
if (!zram_has_control(z) || !(ctl = zram_get_control()))
ul_path_read_string(sysfs, &str, name);
return str;
- } else if (ul_path_read_u64(sysfs, &num, name) == 0)
+ }
+
+ if (ul_path_read_u64(sysfs, &num, name) == 0)
return size_to_human_string(SIZE_SUFFIX_1LETTER, num);
return NULL;
fputs(_("Set up and control zram devices.\n"), out);
fputs(USAGE_OPTIONS, out);
- fputs(_(" -a, --algorithm lzo|lz4|lz4hc|deflate|842 compression algorithm to use\n"), out);
+ fputs(_(" -a, --algorithm <alg> compression algorithm to use\n"), out);
fputs(_(" -b, --bytes print sizes in bytes rather than in human readable format\n"), out);
fputs(_(" -f, --find find a free device\n"), out);
fputs(_(" -n, --noheadings don't print headings\n"), out);
fputs(_(" -t, --streams <number> number of compression streams\n"), out);
fputs(USAGE_SEPARATOR, out);
- printf(USAGE_HELP_OPTIONS(27));
+ fprintf(out, USAGE_HELP_OPTIONS(27));
+
+ fputs(USAGE_ARGUMENTS, out);
+ fprintf(out, USAGE_ARG_SIZE(_("<size>")));
+
+ fputs(_(" <alg> specify algorithm, supported are:\n"), out);
+ fputs(_(" lzo, lz4, lz4hc, deflate, 842 and zstd\n"), out);
+ fputs(_(" (List may be inaccurate, consult man page.)\n"), out);
fputs(USAGE_COLUMNS, out);
for (i = 0; i < ARRAY_SIZE(infos); i++)
fprintf(out, " %11s %s\n", infos[i].name, _(infos[i].help));
- printf(USAGE_MAN_TAIL("zramctl(8)"));
+ fprintf(out, USAGE_MAN_TAIL("zramctl(8)"));
exit(EXIT_SUCCESS);
}
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
while ((c = getopt_long(argc, argv, "a:bfho:nrs:t:V", longopts, NULL)) != -1) {
case 'n':
no_headings = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default: