Commit e38565f5 authored by Matt Caswell's avatar Matt Caswell
Browse files

Fix some style issues



There were a number of places where the async code did not conform to the
OpenSSL coding style.

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
parent 625146d9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -76,7 +76,8 @@ int async_fibre_init(async_fibre *fibre)
{
    void *stack = NULL;

    if (!(stack = OPENSSL_malloc(STACKSIZE))) {
    stack = OPENSSL_malloc(STACKSIZE);
    if (stack == NULL) {
        return 0;
    }

+2 −2
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ int async_fibre_init_dispatcher(async_fibre *fibre)

    dispatcher =
        (LPVOID) CRYPTO_get_thread_local(CRYPTO_THREAD_LOCAL_ASYNC_DISPATCH);
    if (!dispatcher) {
    if (dispatcher == NULL) {
        fibre->fibre = ConvertThreadToFiber(NULL);
        CRYPTO_set_thread_local(CRYPTO_THREAD_LOCAL_ASYNC_DISPATCH,
                                (void *)fibre->fibre);
@@ -125,7 +125,7 @@ int async_set_pool(STACK_OF(ASYNC_JOB) *poolin, size_t curr_size,
{
    struct winpool *pool;
    pool = OPENSSL_malloc(sizeof *pool);
    if (!pool)
    if (pool == NULL)
        return 0;

    pool->pool = poolin;
+34 −32
Original line number Diff line number Diff line
@@ -73,7 +73,8 @@ static async_ctx *async_ctx_new(void)
{
    async_ctx *nctx = NULL;

    if(!(nctx = OPENSSL_malloc(sizeof (async_ctx)))) {
    nctx = OPENSSL_malloc(sizeof (async_ctx));
    if (nctx == NULL) {
        ASYNCerr(ASYNC_F_ASYNC_CTX_NEW, ERR_R_MALLOC_FAILURE);
        goto err;
    }
@@ -86,22 +87,22 @@ static async_ctx *async_ctx_new(void)

    return nctx;
err:
    if(nctx) {
    OPENSSL_free(nctx);
    }

    return NULL;
}

static int async_ctx_free(void)
{
    if(async_get_ctx()) {
        OPENSSL_free(async_get_ctx());
    }
    async_ctx *ctx;

    ctx = async_get_ctx();

    if (!async_set_ctx(NULL))
        return 0;

    OPENSSL_free(ctx);

    return 1;
}

@@ -110,7 +111,8 @@ static ASYNC_JOB *async_job_new(void)
    ASYNC_JOB *job = NULL;
    int pipefds[2];

    if(!(job = OPENSSL_malloc(sizeof (ASYNC_JOB)))) {
    job = OPENSSL_malloc(sizeof (ASYNC_JOB));
    if (job == NULL) {
        ASYNCerr(ASYNC_F_ASYNC_JOB_NEW, ERR_R_MALLOC_FAILURE);
        return NULL;
    }
@@ -133,8 +135,7 @@ static ASYNC_JOB *async_job_new(void)

static void async_job_free(ASYNC_JOB *job)
{
    if(job) {
        if(job->funcargs)
    if (job != NULL) {
        OPENSSL_free(job->funcargs);
        async_fibre_free(&job->fibrectx);
        OPENSSL_free(job);
@@ -172,7 +173,6 @@ static ASYNC_JOB *async_get_pool_job(void) {
}

static void async_release_job(ASYNC_JOB *job) {
    if(job->funcargs)
    OPENSSL_free(job->funcargs);
    job->funcargs = NULL;
    /* Ignore error return */
@@ -204,7 +204,7 @@ void async_start_func(void)
int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *),
                         void *args, size_t size)
{
    if(!async_get_ctx() && !async_ctx_new()) {
    if (async_get_ctx() == NULL && async_ctx_new() == NULL) {
        return ASYNC_ERR;
    }

@@ -213,7 +213,7 @@ int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *),
    }

    for (;;) {
        if(async_get_ctx()->currjob) {
        if (async_get_ctx()->currjob != NULL) {
            if (async_get_ctx()->currjob->status == ASYNC_JOB_STOPPING) {
                *ret = async_get_ctx()->currjob->ret;
                async_release_job(async_get_ctx()->currjob);
@@ -250,13 +250,13 @@ int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *),
        }

        /* Start a new job */
        if(!(async_get_ctx()->currjob = async_get_pool_job())) {
        if ((async_get_ctx()->currjob = async_get_pool_job()) == NULL) {
            return ASYNC_NO_JOBS;
        }

        if (args != NULL) {
            async_get_ctx()->currjob->funcargs = OPENSSL_malloc(size);
            if(!async_get_ctx()->currjob->funcargs) {
            if (async_get_ctx()->currjob->funcargs == NULL) {
                ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_MALLOC_FAILURE);
                async_release_job(async_get_ctx()->currjob);
                async_get_ctx()->currjob = NULL;
@@ -379,7 +379,9 @@ void ASYNC_free_pool(void)
ASYNC_JOB *ASYNC_get_current_job(void)
{
    async_ctx *ctx;
    if((ctx = async_get_ctx()) == NULL)

    ctx = async_get_ctx();
    if(ctx == NULL)
        return NULL;

    return ctx->currjob;