static int get_line(RemoteSource *source, char **line, size_t *size) {
ssize_t n, remain;
- char *c;
+ char *c = NULL;
char *newbuf = NULL;
size_t newsize = 0;
assert(source->filled <= source->size);
assert(source->buf == NULL || source->size > 0);
- c = memchr(source->buf, '\n', source->filled);
+ if (source->buf)
+ c = memchr(source->buf, '\n', source->filled);
+
if (c != NULL)
goto docopy;
resize:
+ if (source->fd < 0)
+ /* we have to wait for some data to come to us */
+ return -EWOULDBLOCK;
+
if (source->size - source->filled < LINE_CHUNK) {
// XXX: add check for maximum line length
assert(data);
while(source->filled < size) {
+ if (source->fd < 0)
+ /* we have to wait for some data to come to us */
+ return -EWOULDBLOCK;
+
if (!GREEDY_REALLOC(source->buf, source->size, size))
return log_oom();
static int get_data_size(RemoteSource *source) {
int r;
- void _cleanup_free_ *data = NULL;
+ _cleanup_free_ void *data = NULL;
assert(source);
assert(source->state == STATE_DATA_START);
static int get_data_newline(RemoteSource *source) {
int r;
- char _cleanup_free_ *data = NULL;
+ _cleanup_free_ char *data = NULL;
assert(source);
assert(source->state == STATE_DATA_FINISH);