This should never be a problem, but better be safe than sorry.
int r;
assert(link);
+ assert(link->ifname);
if (link->state == LINK_STATE_FAILED)
return 1;
int link_save(Link *link) {
_cleanup_free_ char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
+ const char *state;
int r;
assert(link);
assert(link->state_file);
+ state = link_state_to_string(link->state);
+ if (!state)
+ goto finish;
+
r = fopen_temporary(link->state_file, &f, &temp_path);
if (r < 0)
goto finish;
fprintf(f,
"# This is private data. Do not parse.\n"
- "STATE=%s\n",
- link_state_to_string(link->state));
+ "STATE=%s\n", state);
if (link->dhcp_lease) {
_cleanup_free_ char *lease_file = NULL;