Skip to content

Commit

Permalink
Avoid calling VECTOR_size(NULL).
Browse files Browse the repository at this point in the history
  • Loading branch information
darobs committed Apr 25, 2017
1 parent 601c0ac commit 818b421
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
4 changes: 1 addition & 3 deletions core/tests/outprocess_loader_ut/outprocess_loader_ut.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include <stdint.h>
Expand Down Expand Up @@ -1404,8 +1404,6 @@ TEST_FUNCTION(OutprocessLoader_JoinChildProcesses_SCENARIO_no_threads_running)

// Expected call listing
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(VECTOR_size(NULL))
.SetReturn(0);
EXPECTED_CALL(uv_default_loop())
.SetReturn(MOCK_UV_LOOP);
STRICT_EXPECTED_CALL(uv_loop_alive(MOCK_UV_LOOP))
Expand Down
12 changes: 4 additions & 8 deletions proxy/outprocess/src/module_loaders/outprocess_loader.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include "module_loaders/outprocess_loader.h"
Expand Down Expand Up @@ -249,7 +249,7 @@ int OutprocessLoader_SpawnChildProcesses(void) {

void OutprocessLoader_JoinChildProcesses(void) {
/* Codes_SRS_OUTPROCESS_LOADER_27_064: [ `OutprocessLoader_JoinChildProcesses` shall get the count of child processes, by calling `size_t VECTOR_size(VECTOR_HANDLE handle)`. ] */
const size_t child_count = VECTOR_size(uv_processes);
const size_t child_count = (uv_processes == NULL)? 0 :VECTOR_size(uv_processes);

TICK_COUNTER_HANDLE ticks = NULL;
tickcounter_ms_t started_waiting;
Expand Down Expand Up @@ -313,12 +313,8 @@ void OutprocessLoader_JoinChildProcesses(void) {

uv_process_grace_period_ms = 0;

if (NULL == uv_thread)
{
/* Codes_SRS_OUTPROCESS_LOADER_27_050: [ Prerequisite Check - If no threads are running, then `OutprocessLoader_JoinChildProcesses` shall abandon the effort to join the child processes immediately. ] */
LogInfo("The process management thread is not currently running.");
}
else
/* Codes_SRS_OUTPROCESS_LOADER_27_050: [ Prerequisite Check - If no threads are running, then `OutprocessLoader_JoinChildProcesses` shall abandon the effort to join the child processes immediately. ] */
if (NULL != uv_thread)
{
/* Codes_SRS_OUTPROCESS_LOADER_27_062: [ `OutprocessLoader_JoinChildProcesses` shall join the child process management thread, by calling `THREADAPI_RESULT ThreadAPI_Join(THREAD_HANDLE threadHandle, int * res)`. ] */
(void)ThreadAPI_Join(uv_thread, &uv_thread_result);
Expand Down

0 comments on commit 818b421

Please sign in to comment.