mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-03 13:20:25 -05:00
replace raw C-strings with std::string in converted libfuse files
util/mount.mergerfs.cpp: - Remove xstrdup/xrealloc wrappers entirely - Convert type, source, options, command, setuid to std::string - Replace add_arg() pointer-rewriting with shell_quote() returning std::string - Replace add_option() with simple std::string += concatenation - Fix const_cast UB on string literal assignment lib/helper.cpp: - Convert add_default_subtype local subtype_opt: malloc+snprintf+free -> std::string construction lib/mount_generic.h: - Convert fuse_mount_sys locals source/type: malloc+strcpy+strcat -> std::string - Remove 4 unnecessary free() calls (RAII cleanup) - .c_str() at mount() and fuse_mnt_add_mount() boundaries lib/mount_util.h: - Rewrite fuse_mnt_resolve_path internals using std::string: rfind/substr instead of manual pointer arithmetic, strrchr, strlen chains
This commit is contained in:
parent
21966ade97
commit
0cfab60f37
4 changed files with 127 additions and 202 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
|
@ -86,24 +87,14 @@ fuse_helper_opt_proc(void *data,
|
|||
|
||||
static int add_default_subtype(const char *progname, struct fuse_args *args)
|
||||
{
|
||||
int res;
|
||||
char *subtype_opt;
|
||||
const char *basename = strrchr(progname, '/');
|
||||
if (basename == NULL)
|
||||
basename = progname;
|
||||
else if (basename[1] != '\0')
|
||||
basename++;
|
||||
|
||||
size_t optlen = strlen(basename) + 64;
|
||||
subtype_opt = (char *) malloc(optlen);
|
||||
if (subtype_opt == NULL) {
|
||||
fprintf(stderr, "fuse: memory allocation failed\n");
|
||||
return -1;
|
||||
}
|
||||
snprintf(subtype_opt, optlen, "-osubtype=%s", basename);
|
||||
res = fuse_opt_add_arg(args, subtype_opt);
|
||||
free(subtype_opt);
|
||||
return res;
|
||||
std::string subtype_opt = "-osubtype=" + std::string(basename);
|
||||
return fuse_opt_add_arg(args, subtype_opt.c_str());
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue