chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prep v225: Applying various fixes and changes to src/basic that got lost during git...
[elogind.git]
/
src
/
basic
/
fileio.c
diff --git
a/src/basic/fileio.c
b/src/basic/fileio.c
index db2c46cfb1d8e76dca4f599d44e41aac42f2143f..f666380a414e8f5554c9f2511d932aca3c5519bd 100644
(file)
--- a/
src/basic/fileio.c
+++ b/
src/basic/fileio.c
@@
-28,21
+28,15
@@
#include "fileio.h"
int write_string_stream(FILE *f, const char *line, bool enforce_newline) {
#include "fileio.h"
int write_string_stream(FILE *f, const char *line, bool enforce_newline) {
+
assert(f);
assert(line);
assert(f);
assert(line);
- errno = 0;
-
fputs(line, f);
if (enforce_newline && !endswith(line, "\n"))
fputc('\n', f);
fputs(line, f);
if (enforce_newline && !endswith(line, "\n"))
fputc('\n', f);
- fflush(f);
-
- if (ferror(f))
- return errno ? -errno : -EIO;
-
- return 0;
+ return fflush_and_check(f);
}
static int write_string_file_atomic(const char *fn, const char *line, bool enforce_newline) {
}
static int write_string_file_atomic(const char *fn, const char *line, bool enforce_newline) {
@@
-795,7
+789,7
@@
int executable_is_script(const char *path, char **interpreter) {
*/
int get_status_field(const char *filename, const char *pattern, char **field) {
_cleanup_free_ char *status = NULL;
*/
int get_status_field(const char *filename, const char *pattern, char **field) {
_cleanup_free_ char *status = NULL;
- char *t;
+ char *t
, *f
;
size_t len;
int r;
size_t len;
int r;
@@
-829,9
+823,10
@@
int get_status_field(const char *filename, const char *pattern, char **field) {
len = strcspn(t, WHITESPACE);
len = strcspn(t, WHITESPACE);
-
*field
= strndup(t, len);
- if (!
*field
)
+
f
= strndup(t, len);
+ if (!
f
)
return -ENOMEM;
return -ENOMEM;
+ *field = f;
return 0;
}
return 0;
}