aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-06-11 15:20:00 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-06-11 15:20:00 +0300
commit0c217c3b1d3a9f61e3b095921fe91013324414cb (patch)
tree13e3cef3f11aab2f38e0af7e48e141686ebfde9b
parent02e5e51c36910f54324ad1c82d2a6db38d838876 (diff)
downloadsmap-0c217c3b1d3a9f61e3b095921fe91013324414cb.tar.gz
smap-0c217c3b1d3a9f61e3b095921fe91013324414cb.tar.bz2
Bugfixes.
* src/smapc.c (user_file_name): Fix memory allocation error. * lib/stream.c: Minor style fixes.
-rw-r--r--lib/stream.c34
-rw-r--r--src/smapc.c2
2 files changed, 18 insertions, 18 deletions
diff --git a/lib/stream.c b/lib/stream.c
index ea255e7..4faaa32 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -104,9 +104,9 @@ _stream_fill_line_buffered(struct _smap_stream *stream)
for (n = 0;
n < stream->bufsize &&
- (rc = smap_stream_read_unbuffered (stream,
- &c, 1,
- 0, &rdn)) == 0
+ (rc = smap_stream_read_unbuffered(stream,
+ &c, 1,
+ 0, &rdn)) == 0
&& rdn; ) {
stream->buffer[n++] = c;
if (c == '\n')
@@ -214,7 +214,7 @@ _stream_flush_buffer(struct _smap_stream *stream, int all)
return rc;
_stream_advance_buffer(stream, size);
}
- if ((all && stream->level) || BUFFER_FULL_P (stream)) {
+ if ((all && stream->level) || BUFFER_FULL_P(stream)) {
rc = smap_stream_write_unbuffered(stream,
stream->cur,
stream->level,
@@ -292,8 +292,8 @@ smap_stream_open(smap_stream_t stream)
{
int rc;
- if (stream->open && (rc = stream->open (stream)))
- return _stream_seterror (stream, rc, 1);
+ if (stream->open && (rc = stream->open(stream)))
+ return _stream_seterror(stream, rc, 1);
stream->bytes_in = stream->bytes_out = 0;
return 0;
}
@@ -489,7 +489,7 @@ smap_stream_read_unbuffered(smap_stream_t stream, void *buf, size_t size,
return _stream_seterror(stream, ENOSYS, 0);
if (!(stream->flags & SMAP_STREAM_READ))
- return _stream_seterror (stream, EACCES, 1);
+ return _stream_seterror(stream, EACCES, 1);
if (stream->flags & _SMAP_STR_ERR)
return stream->last_err;
@@ -680,7 +680,7 @@ _stream_readdelim(smap_stream_t stream, char *buf, size_t size,
return EOVERFLOW;
for (n = 0;
n < size &&
- (rc = smap_stream_read (stream, &c, 1, &rdn)) == 0 &&
+ (rc = smap_stream_read(stream, &c, 1, &rdn)) == 0 &&
rdn;) {
*buf++ = c;
n++;
@@ -754,7 +754,7 @@ smap_stream_getdelim(smap_stream_t stream, char **pbuf, size_t *psize,
break;
}
- new_lineptr = realloc (lineptr, needed);
+ new_lineptr = realloc(lineptr, needed);
if (new_lineptr == NULL) {
rc = ENOMEM;
break;
@@ -841,8 +841,8 @@ int
smap_stream_writeline(smap_stream_t stream, const char *buf, size_t size)
{
int rc;
- if ((rc = smap_stream_write (stream, buf, size, NULL)) == 0)
- rc = smap_stream_write (stream, "\r\n", 2, NULL);
+ if ((rc = smap_stream_write(stream, buf, size, NULL)) == 0)
+ rc = smap_stream_write(stream, "\r\n", 2, NULL);
return rc;
}
@@ -853,11 +853,11 @@ smap_stream_flush(smap_stream_t stream)
if (!stream)
return EINVAL;
- rc = _stream_flush_buffer (stream, 1);
+ rc = _stream_flush_buffer(stream, 1);
if (rc)
return rc;
if ((stream->flags & _SMAP_STR_WRT) && stream->flush)
- return stream->flush (stream);
+ return stream->flush(stream);
stream->flags &= ~_SMAP_STR_WRT;
return 0;
}
@@ -885,7 +885,7 @@ smap_stream_size(smap_stream_t stream, smap_off_t *psize)
if (!stream->size)
return _stream_seterror(stream, ENOSYS, 0);
- rc = stream->size (stream, psize);
+ rc = stream->size(stream, psize);
return _stream_seterror(stream, rc, rc != 0);
}
@@ -926,7 +926,7 @@ smap_stream_wait(smap_stream_t stream, int *pflags, struct timeval *tvp)
}
if (stream->wait) {
- int rc = stream->wait (stream, pflags, tvp);
+ int rc = stream->wait(stream, pflags, tvp);
if (rc == 0)
*pflags |= flg;
return rc;
@@ -939,7 +939,7 @@ int
smap_stream_truncate(smap_stream_t stream, smap_off_t size)
{
if (stream->truncate)
- return stream->truncate (stream, size);
+ return stream->truncate(stream, size);
return ENOSYS;
}
@@ -947,7 +947,7 @@ int
smap_stream_shutdown(smap_stream_t stream, int how)
{
if (stream->shutdown)
- return stream->shutdown (stream, how);
+ return stream->shutdown(stream, how);
return ENOSYS;
}
diff --git a/src/smapc.c b/src/smapc.c
index a403813..cfa75ce 100644
--- a/src/smapc.c
+++ b/src/smapc.c
@@ -169,7 +169,7 @@ user_file_name(const char *name, const char *suffix)
}
}
size = strlen(home) + 2 + strlen(name)
- + (suffix ? strlen(suffix) : 0) ;
+ + (suffix ? strlen(suffix) : 0) + 1;
filename = emalloc(size);
strcpy(filename, home);
strcat(filename, "/.");

Return to:

Send suggestions and report system problems to the System administrator.