Commit 6d7033b4 authored by Willem Sparreboom's avatar Willem Sparreboom Committed by Daniel Stenberg
Browse files

PolarSSL: Change to cURL coding style

Repaired all curl/lib/checksrc.pl warnings in the previous four patches
parent f10006ee
Loading
Loading
Loading
Loading
+21 −21
Original line number Diff line number Diff line
@@ -89,8 +89,7 @@ static void entropy_init_mutex(entropy_context *ctx)
{
  /* lock 0 = entropy_init_mutex() */
  polarsslthreadlock_lock_function(0);
    if(entropy_init_initialized == 0)
    {
  if(entropy_init_initialized == 0) {
    entropy_init(ctx);
    entropy_init_initialized = 1;
  }
@@ -171,23 +170,23 @@ polarssl_connect_step1(struct connectdata *conn,
  entropy_init_mutex(&entropy);

  if((ret = ctr_drbg_init(&connssl->ctr_drbg, entropy_func_mutex, &entropy,
                           connssl->ssn.id, connssl->ssn.length)) != 0)
  {
                               connssl->ssn.id, connssl->ssn.length)) != 0) {
#ifdef POLARSSL_ERROR_C
     error_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* POLARSSL_ERROR_C */
	 failf(data, "Failed - PolarSSL: ctr_drbg_init returned (-0x%04X) %s\n", -ret, errorbuf);
     failf(data, "Failed - PolarSSL: ctr_drbg_init returned (-0x%04X) %s\n",
                                                            -ret, errorbuf);
  }
#else
  entropy_init(&connssl->entropy);

  if((ret = ctr_drbg_init(&connssl->ctr_drbg, entropy_func, &connssl->entropy,
                           connssl->ssn.id, connssl->ssn.length)) != 0)
  {
                                connssl->ssn.id, connssl->ssn.length)) != 0) {
#ifdef POLARSSL_ERROR_C
     error_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* POLARSSL_ERROR_C */
	 failf(data, "Failed - PolarSSL: ctr_drbg_init returned (-0x%04X) %s\n", -ret, errorbuf);
     failf(data, "Failed - PolarSSL: ctr_drbg_init returned (-0x%04X) %s\n",
                                                            -ret, errorbuf);
  }
#endif /* THREADING_SUPPORT */
#endif /* POLARSSL_VERSION_NUMBER<0x01010000 */
@@ -356,7 +355,8 @@ polarssl_connect_step2(struct connectdata *conn,
#ifdef POLARSSL_ERROR_C
     error_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* POLARSSL_ERROR_C */
	  failf(data, "ssl_handshake returned - PolarSSL: (-0x%04X) %s", -ret, errorbuf);
     failf(data, "ssl_handshake returned - PolarSSL: (-0x%04X) %s",
                                                    -ret, errorbuf);

     return CURLE_SSL_CONNECT_ERROR;
    }
+43 −48
Original line number Diff line number Diff line
@@ -24,7 +24,8 @@
#include <stdio.h>
#include "curl_setup.h"

#if defined(USE_POLARSSL) && (defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32))
#if defined(USE_POLARSSL) && \
    (defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32))

#if defined(USE_THREADS_POSIX)
#ifdef HAVE_PTHREAD_H
@@ -56,15 +57,13 @@ int polarsslthreadlock_thread_setup(void)
    return 0;     /* error, no number of threads defined */

#ifdef HAVE_PTHREAD_H
  for (i = 0;  i < NUMT;  i++)
  {
  for(i = 0;  i < NUMT;  i++) {
    ret = pthread_mutex_init(&mutex_buf[i], NULL);
    if(ret)
      return 0; /* pthread_mutex_init failed */
  }
#elif defined(HAVE_PROCESS_H)
  for (i = 0;  i < NUMT;  i++)
  {
  for(i = 0;  i < NUMT;  i++) {
    mutex_buf[i] = CreateMutex(0, FALSE, 0);
    if(mutex_buf[i] == 0)
      return 0;  /* CreateMutex failed */
@@ -83,17 +82,17 @@ int polarsslthreadlock_thread_cleanup(void)
    return 0; /* error, no threads locks defined */

#ifdef HAVE_PTHREAD_H
  for (i = 0; i < NUMT; i++)
  {
  for(i = 0; i < NUMT; i++) {
    ret = pthread_mutex_destroy(&mutex_buf[i]);
    if(ret)
      return 0; /* pthread_mutex_destroy failed */
  }
#elif defined(HAVE_PROCESS_H)
  for (i = 0; i < NUMT; i++)
  for(i = 0; i < NUMT; i++) {
    ret = CloseHandle(mutex_buf[i]);
    if(!ret)
      return 0; /* CloseHandle failed */
  }
#endif /* HAVE_PTHREAD_H */
  free(mutex_buf);
  mutex_buf = NULL;
@@ -105,22 +104,20 @@ int polarsslthreadlock_lock_function(int n)
{
  int ret;
#ifdef HAVE_PTHREAD_H
  if(n < NUMT)
  {
  if(n < NUMT) {
    ret = pthread_mutex_lock(&mutex_buf[n]);
	if(ret)
	{
	  DEBUGF(fprintf(stderr, "Error: polarsslthreadlock_lock_function failed\n"));
    if(ret) {
      DEBUGF(fprintf(stderr,
                     "Error: polarsslthreadlock_lock_function failed\n"));
      return 0; /* pthread_mutex_lock failed */
    }
  }
#elif defined(HAVE_PROCESS_H)
  if(n < NUMT)
  {
  if(n < NUMT) {
    ret = (WaitForSingleObject(mutex_buf[n], INFINITE)==WAIT_FAILED?1:0);
	if(ret)
	{
	  DEBUGF(fprintf(stderr, "Error: polarsslthreadlock_lock_function failed\n"));
    if(ret) {
      DEBUGF(fprintf(stderr,
                     "Error: polarsslthreadlock_lock_function failed\n"));
      return 0; /* pthread_mutex_lock failed */
    }
  }
@@ -132,22 +129,20 @@ int polarsslthreadlock_unlock_function(int n)
{
  int ret;
#ifdef HAVE_PTHREAD_H
  if(n < NUMT)
  {
  if(n < NUMT) {
    ret = pthread_mutex_unlock(&mutex_buf[n]);
	if(ret)
	{
	  DEBUGF(fprintf(stderr, "Error: polarsslthreadlock_unlock_function failed\n"));
    if(ret) {
      DEBUGF(fprintf(stderr,
                     "Error: polarsslthreadlock_unlock_function failed\n"));
      return 0; /* pthread_mutex_unlock failed */
    }
  }
#elif defined(HAVE_PROCESS_H)
  if(n < NUMT)
  {
  if(n < NUMT) {
    ret = ReleaseMutex(mutex_buf[n]);
	if(!ret)
	{
	  DEBUGF(fprintf(stderr, "Error: polarsslthreadlock_unlock_function failed\n"));
    if(!ret) {
      DEBUGF(fprintf(stderr,
                     "Error: polarsslthreadlock_unlock_function failed\n"));
      return 0; /* pthread_mutex_lock failed */
    }
  }