From commits-return-4503-archive-asf-public=cust-asf.ponee.io@celix.apache.org Tue Jan 30 20:19:02 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 718FC18066D for ; Tue, 30 Jan 2018 20:19:01 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 61699160C72; Tue, 30 Jan 2018 19:19:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 24860160C56 for ; Tue, 30 Jan 2018 20:18:59 +0100 (CET) Received: (qmail 13655 invoked by uid 500); 30 Jan 2018 19:18:59 -0000 Mailing-List: contact commits-help@celix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@celix.apache.org Delivered-To: mailing list commits@celix.apache.org Received: (qmail 13322 invoked by uid 99); 30 Jan 2018 19:18:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Jan 2018 19:18:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 04D78F4DBC; Tue, 30 Jan 2018 19:18:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pnoltes@apache.org To: commits@celix.apache.org Date: Tue, 30 Jan 2018 19:19:20 -0000 Message-Id: <05d221a732254841ab1a86b6d81904e6@git.apache.org> In-Reply-To: <1b421c6c690a4bc49fda2e206ddf3a76@git.apache.org> References: <1b421c6c690a4bc49fda2e206ddf3a76@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [24/50] [abbrv] celix git commit: Fixed Coverity issues Fixed Coverity issues Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/361abd71 Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/361abd71 Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/361abd71 Branch: refs/heads/master Commit: 361abd711d9d3a3dafe42a296a117962d03258c5 Parents: 4da7947 Author: gricciardi Authored: Wed Nov 15 18:45:58 2017 +0100 Committer: gricciardi Committed: Wed Nov 15 18:45:58 2017 +0100 ---------------------------------------------------------------------- shell_tui/private/src/shell_tui.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/361abd71/shell_tui/private/src/shell_tui.c ---------------------------------------------------------------------- diff --git a/shell_tui/private/src/shell_tui.c b/shell_tui/private/src/shell_tui.c index de16a20..28bedaa 100644 --- a/shell_tui/private/src/shell_tui.c +++ b/shell_tui/private/src/shell_tui.c @@ -66,9 +66,9 @@ struct shell_tui { }; typedef struct shell_context { - char in[LINE_SIZE]; - char buffer[LINE_SIZE]; - char dline[LINE_SIZE]; + char in[LINE_SIZE+1]; + char buffer[LINE_SIZE+1]; + char dline[LINE_SIZE+1]; int pos; history_t* hist; } shell_context_t; @@ -101,8 +101,13 @@ celix_status_t shellTui_start(shell_tui_t* shellTui) { if (rc == 0) { shellTui->readPipeFd = fds[0]; shellTui->writePipeFd = fds[1]; - fcntl(shellTui->writePipeFd, F_SETFL, O_NONBLOCK); - celixThread_create(&shellTui->thread, NULL, shellTui_runnable, shellTui); + if(fcntl(shellTui->writePipeFd, F_SETFL, O_NONBLOCK) == 0){ + celixThread_create(&shellTui->thread, NULL, shellTui_runnable, shellTui); + } + else{ + fprintf(stderr,"fcntl on pipe failed"); + status = CELIX_FILE_IO_EXCEPTION; + } } else { fprintf(stderr, "Cannot create pipe"); status = CELIX_BUNDLE_EXCEPTION; @@ -229,6 +234,10 @@ static void shellTui_parseInputForControl(shell_tui_t* shellTui, shell_context_t char* line = NULL; + if (shellTui == NULL) { + return; + } + int nr_chars = read(STDIN_FILENO, buffer, LINE_SIZE-pos-1); for(int bufpos = 0; bufpos < nr_chars; bufpos++) { if (buffer[bufpos] == KEY_ESC1 && buffer[bufpos+1] == KEY_ESC2) { @@ -289,9 +298,7 @@ static void shellTui_parseInputForControl(shell_tui_t* shellTui, shell_context_t continue; } else if(buffer[bufpos] == KEY_TAB) { celixThreadMutex_lock(&shellTui->mutex); - if (shellTui != NULL) { - pos = autoComplete(shellTui->shell, in, pos, LINE_SIZE); - } + pos = autoComplete(shellTui->shell, in, pos, LINE_SIZE); celixThreadMutex_unlock(&shellTui->mutex); continue; } else if (buffer[bufpos] != KEY_ENTER) { //not end of line -> text