summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-12-11 18:42:35 +0100
committerDave Davenport <qball@gmpclient.org>2017-12-11 18:42:35 +0100
commit5a200947778c1a4e0a3bdca9d8214ef4fc8eb830 (patch)
treeb2a11a2d917f0ee5d0cff8a44bcaa639e34f9175 /source
parent2cbbb1606fd963c524a87257078065f86a68cf18 (diff)
[Script] Reduce scope and swap tests. (cppcheck)
Diffstat (limited to 'source')
-rw-r--r--source/dialogs/script.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/source/dialogs/script.c b/source/dialogs/script.c
index 05cfcb29..9daf1354 100644
--- a/source/dialogs/script.c
+++ b/source/dialogs/script.c
@@ -69,7 +69,7 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
{
ScriptModePrivateData *pd = (ScriptModePrivateData *) sw->private_data;
ssize_t length_key = 0;//strlen ( line );
- while ( line[length_key] != '\x1f' && length_key <= length ) {
+ while ( length_key <= length && line[length_key] != '\x1f' ) {
length_key++;
}
@@ -99,7 +99,6 @@ static void parse_header_entry ( Mode *sw, char *line, ssize_t length )
static char **get_script_output ( Mode *sw, char *command, char *arg, unsigned int *length )
{
- size_t actual_size = 0;
int fd = -1;
GError *error = NULL;
char **retv = NULL;
@@ -126,6 +125,7 @@ static char **get_script_output ( Mode *sw, char *command, char *arg, unsigned i
char *buffer = NULL;
size_t buffer_length = 0;
ssize_t read_length = 0;
+ size_t actual_size = 0;
while ( ( read_length = getline ( &buffer, &buffer_length, inp ) ) > 0 ) {
// Filter out line-end.
if ( buffer[read_length - 1] == '\n' ) {