mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 04:28:29 +02:00
shared: add nmtst_auto_unlinkfile cleanup macro
This commit is contained in:
parent
b204801b7e
commit
f5e6f1d65b
1 changed files with 42 additions and 0 deletions
|
|
@ -1158,6 +1158,48 @@ nmtst_file_get_contents (const char *filename)
|
|||
return contents;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
inline static void
|
||||
nmtst_file_unlink_if_exists (const char *name)
|
||||
{
|
||||
int errsv;
|
||||
|
||||
g_assert (name && name[0]);
|
||||
|
||||
if (unlink (name) != 0) {
|
||||
errsv = errno;
|
||||
if (errsv != ENOENT)
|
||||
g_error ("nmtst_file_unlink_if_exists(%s): failed with %s", name, strerror (errsv));
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
nmtst_file_unlink (const char *name)
|
||||
{
|
||||
int errsv;
|
||||
|
||||
g_assert (name && name[0]);
|
||||
|
||||
if (unlink (name) != 0) {
|
||||
errsv = errno;
|
||||
g_error ("nmtst_file_unlink(%s): failed with %s", name, strerror (errsv));
|
||||
}
|
||||
}
|
||||
|
||||
inline static void
|
||||
_nmtst_auto_unlinkfile (char **p_name)
|
||||
{
|
||||
if (*p_name) {
|
||||
nmtst_file_unlink (*p_name);
|
||||
nm_clear_g_free (p_name);
|
||||
}
|
||||
}
|
||||
|
||||
#define nmtst_auto_unlinkfile nm_auto(_nmtst_auto_unlinkfile)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
inline static void
|
||||
_nmtst_assert_resolve_relative_path_equals (const char *f1, const char *f2, const char *file, int line)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue