src: changed usage of basename() to path_extract_filename().
TODO.
This commit is contained in:
committed by
Luca Boccassi
parent
ee9fc74a4c
commit
de2820606d
+13
-4
@@ -71,10 +71,11 @@ int unit_symlink_name_compatible(const char *symlink, const char *target, bool i
|
||||
}
|
||||
|
||||
int unit_validate_alias_symlink_or_warn(int log_level, const char *filename, const char *target) {
|
||||
const char *src, *dst;
|
||||
_cleanup_free_ char *src = NULL, *dst = NULL;
|
||||
_cleanup_free_ char *src_instance = NULL, *dst_instance = NULL;
|
||||
UnitType src_unit_type, dst_unit_type;
|
||||
UnitNameFlags src_name_type, dst_name_type;
|
||||
int r;
|
||||
|
||||
/* Check if the *alias* symlink is valid. This applies to symlinks like
|
||||
* /etc/systemd/system/dbus.service → dbus-broker.service, but not to .wants or .requires symlinks
|
||||
@@ -87,8 +88,13 @@ int unit_validate_alias_symlink_or_warn(int log_level, const char *filename, con
|
||||
* -ELOOP for an alias to self.
|
||||
*/
|
||||
|
||||
src = basename(filename);
|
||||
dst = basename(target);
|
||||
r = path_extract_filename(filename, &src);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = path_extract_filename(target, &dst);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* src checks */
|
||||
|
||||
@@ -762,7 +768,10 @@ int unit_file_find_fragment(
|
||||
}
|
||||
|
||||
if (fragment && ret_names) {
|
||||
const char *fragment_basename = basename(fragment);
|
||||
_cleanup_free_ char *fragment_basename = NULL;
|
||||
r = path_extract_filename(fragment, &fragment_basename);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!streq(fragment_basename, unit_name)) {
|
||||
/* Add names based on the fragment name to the set of names */
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "ether-addr-util.h"
|
||||
#include "networkd-manager.h"
|
||||
#include "networkd-network-bus.h"
|
||||
#include "path-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
|
||||
@@ -54,8 +55,8 @@ static const sd_bus_vtable network_vtable[] = {
|
||||
};
|
||||
|
||||
static char *network_bus_path(Network *network) {
|
||||
_cleanup_free_ char *name = NULL;
|
||||
char *networkname, *d, *path;
|
||||
_cleanup_free_ char *name = NULL, *networkname= NULL;
|
||||
char *d, *path;
|
||||
int r;
|
||||
|
||||
assert(network);
|
||||
@@ -65,7 +66,9 @@ static char *network_bus_path(Network *network) {
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
networkname = basename(name);
|
||||
r = path_extract_filename(name, &networkname);
|
||||
if (r < 0)
|
||||
return NULL;
|
||||
|
||||
d = strrchr(networkname, '.');
|
||||
if (!d)
|
||||
|
||||
Reference in New Issue
Block a user