Re: [PATCH] remove macros only used once

2014-04-22 Thread Bob Beck
Once we have that done we might at an opportune time ask our intrepid
ports builders to find out for us who
is using that little gem, and we could *conisder* removing it then if
we're certain nobody has walked in looking like
an Oatmeal-drawn dog and said "Oh boy Oh boy.. ANOTHER malloc wrapper
I can use! I must use it!"


On Tue, Apr 22, 2014 at 6:23 PM, Bob Beck  wrote:
> I  hate the amount of useless garbage API this thing exposes
> externally, that we then have to wonder "WTF out there might use
> it..".. G.
>
> Dirk the right way to do this is leave the macros for now (ick) but
> change the internals of all our stuff to use intrinsics
> without the use of the macros. We don't want to be monkeying with the
> visible API, much, if we can help it.
>
>
> On Tue, Apr 22, 2014 at 6:16 PM, Dirk Engling  wrote:
>>
>>> Note that asn1_mac.h is installed...
>>
>>
>> You're right, I found it referenced at least here:
>>
>> http://opensource.apple.com/source/OpenSSL/OpenSSL-5/openssl/crypto/asn1/p5_pbev2.c
>>
>>   erdgeist
>>



Re: [PATCH] remove macros only used once

2014-04-22 Thread Bob Beck
I  hate the amount of useless garbage API this thing exposes
externally, that we then have to wonder "WTF out there might use
it..".. G.

Dirk the right way to do this is leave the macros for now (ick) but
change the internals of all our stuff to use intrinsics
without the use of the macros. We don't want to be monkeying with the
visible API, much, if we can help it.


On Tue, Apr 22, 2014 at 6:16 PM, Dirk Engling  wrote:
>
>> Note that asn1_mac.h is installed...
>
>
> You're right, I found it referenced at least here:
>
> http://opensource.apple.com/source/OpenSSL/OpenSSL-5/openssl/crypto/asn1/p5_pbev2.c
>
>   erdgeist
>



Re: [PATCH] remove macros only used once

2014-04-22 Thread Dirk Engling



Note that asn1_mac.h is installed...


You're right, I found it referenced at least here:

http://opensource.apple.com/source/OpenSSL/OpenSSL-5/openssl/crypto/asn1/p5_pbev2.c

  erdgeist



Re: [PATCH] remove macros only used once

2014-04-22 Thread Jérémie Courrèges-Anglas
Bob Beck  writes:

> I will be a minute reading this. The comment from the context at the
> bottom of the diff has
> me laughing and crying again...

Note that asn1_mac.h is installed...

> On Tue, Apr 22, 2014 at 5:43 PM, Dirk Engling  wrote:
>> remove M_ASN1_New_Malloc, M_ASN1_New, M_ASN1_New_Error marcos, they hide
>> a malloc and are only used once
>>
>>
>> Index: x_pkey.c
>> ===
>> RCS file: /cvs/src/lib/libssl/src/crypto/asn1/x_pkey.c,v
>> retrieving revision 1.10
>> diff -u -r1.10 x_pkey.c
>> --- x_pkey.c18 Apr 2014 11:20:32 -  1.10
>> +++ x_pkey.c22 Apr 2014 23:43:03 -
>> @@ -109,10 +109,18 @@
>> X509_PKEY *ret = NULL;
>> ASN1_CTX c;
>>
>> -   M_ASN1_New_Malloc(ret, X509_PKEY);
>> +   if ((ret = malloc(sizeof(X509_PKEY))) == NULL )
>> +   ASN1_MAC_H_err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE,
>> +   __LINE__ );
>> +   return NULL;
>> +   }
>> ret->version = 0;
>> -   M_ASN1_New(ret->enc_algor, X509_ALGOR_new);
>> -   M_ASN1_New(ret->enc_pkey, M_ASN1_OCTET_STRING_new);
>> +   ret->enc_algor = X509_ALGOR_new();
>> +   if (ret->enc_algor == NULL)
>> +   return NULL;
>> +   ret->enc_pkey = M_ASN1_OCTET_STRING_new();
>> +   if (ret->enc_pkey == NULL)
>> +   return NULL;
>> ret->dec_pkey = NULL;
>> ret->key_length = 0;
>> ret->key_data = NULL;
>> @@ -121,7 +129,6 @@
>> memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH);
>> ret->references = 1;
>> return (ret);
>> -   M_ASN1_New_Error(ASN1_F_X509_PKEY_NEW);
>>  }
>>
>>  void
>> Index: asn1_mac.h
>> ===
>> RCS file: /cvs/src/lib/libssl/src/crypto/asn1/asn1_mac.h,v
>> retrieving revision 1.10
>> diff -u -r1.10 asn1_mac.h
>> --- asn1_mac.h  17 Apr 2014 13:37:48 -  1.10
>> +++ asn1_mac.h  22 Apr 2014 23:43:03 -
>> @@ -287,21 +287,6 @@
>> c.slen-=(c.p-c.q); \
>> }
>>
>> -/* New macros */
>> -#define M_ASN1_New_Malloc(ret,type) \
>> -   if ((ret=(type *)malloc(sizeof(type))) == NULL) \
>> -   { c.line=__LINE__; goto err2; }
>> -
>> -#define M_ASN1_New(arg,func) \
>> -   if (((arg)=func()) == NULL) return(NULL)
>> -
>> -#define M_ASN1_New_Error(a) \
>> -/* err:ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \
>> -   return(NULL);*/ \
>> -   err2:   ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \
>> -   return(NULL)
>> -
>> -
>>  /* BIG UGLY WARNING!  This is so damn ugly I wanna puke.  Unfortunately,
>> some macros that use ASN1_const_CTX still insist on writing in the input
>> stream.  ARGH!  ARGH!  ARGH!  Let's get rid of this macro package.
>>
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: [PATCH] remove macros only used once

2014-04-22 Thread Bob Beck
I will be a minute reading this. The comment from the context at the
bottom of the diff has
me laughing and crying again...


On Tue, Apr 22, 2014 at 5:43 PM, Dirk Engling  wrote:
> remove M_ASN1_New_Malloc, M_ASN1_New, M_ASN1_New_Error marcos, they hide
> a malloc and are only used once
>
>
> Index: x_pkey.c
> ===
> RCS file: /cvs/src/lib/libssl/src/crypto/asn1/x_pkey.c,v
> retrieving revision 1.10
> diff -u -r1.10 x_pkey.c
> --- x_pkey.c18 Apr 2014 11:20:32 -  1.10
> +++ x_pkey.c22 Apr 2014 23:43:03 -
> @@ -109,10 +109,18 @@
> X509_PKEY *ret = NULL;
> ASN1_CTX c;
>
> -   M_ASN1_New_Malloc(ret, X509_PKEY);
> +   if ((ret = malloc(sizeof(X509_PKEY))) == NULL )
> +   ASN1_MAC_H_err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE,
> +   __LINE__ );
> +   return NULL;
> +   }
> ret->version = 0;
> -   M_ASN1_New(ret->enc_algor, X509_ALGOR_new);
> -   M_ASN1_New(ret->enc_pkey, M_ASN1_OCTET_STRING_new);
> +   ret->enc_algor = X509_ALGOR_new();
> +   if (ret->enc_algor == NULL)
> +   return NULL;
> +   ret->enc_pkey = M_ASN1_OCTET_STRING_new();
> +   if (ret->enc_pkey == NULL)
> +   return NULL;
> ret->dec_pkey = NULL;
> ret->key_length = 0;
> ret->key_data = NULL;
> @@ -121,7 +129,6 @@
> memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH);
> ret->references = 1;
> return (ret);
> -   M_ASN1_New_Error(ASN1_F_X509_PKEY_NEW);
>  }
>
>  void
> Index: asn1_mac.h
> ===
> RCS file: /cvs/src/lib/libssl/src/crypto/asn1/asn1_mac.h,v
> retrieving revision 1.10
> diff -u -r1.10 asn1_mac.h
> --- asn1_mac.h  17 Apr 2014 13:37:48 -  1.10
> +++ asn1_mac.h  22 Apr 2014 23:43:03 -
> @@ -287,21 +287,6 @@
> c.slen-=(c.p-c.q); \
> }
>
> -/* New macros */
> -#define M_ASN1_New_Malloc(ret,type) \
> -   if ((ret=(type *)malloc(sizeof(type))) == NULL) \
> -   { c.line=__LINE__; goto err2; }
> -
> -#define M_ASN1_New(arg,func) \
> -   if (((arg)=func()) == NULL) return(NULL)
> -
> -#define M_ASN1_New_Error(a) \
> -/* err:ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \
> -   return(NULL);*/ \
> -   err2:   ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \
> -   return(NULL)
> -
> -
>  /* BIG UGLY WARNING!  This is so damn ugly I wanna puke.  Unfortunately,
> some macros that use ASN1_const_CTX still insist on writing in the input
> stream.  ARGH!  ARGH!  ARGH!  Let's get rid of this macro package.
>



[PATCH] remove macros only used once

2014-04-22 Thread Dirk Engling
remove M_ASN1_New_Malloc, M_ASN1_New, M_ASN1_New_Error marcos, they hide
a malloc and are only used once


Index: x_pkey.c
===
RCS file: /cvs/src/lib/libssl/src/crypto/asn1/x_pkey.c,v
retrieving revision 1.10
diff -u -r1.10 x_pkey.c
--- x_pkey.c18 Apr 2014 11:20:32 -  1.10
+++ x_pkey.c22 Apr 2014 23:43:03 -
@@ -109,10 +109,18 @@
X509_PKEY *ret = NULL;
ASN1_CTX c;

-   M_ASN1_New_Malloc(ret, X509_PKEY);
+   if ((ret = malloc(sizeof(X509_PKEY))) == NULL )
+   ASN1_MAC_H_err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE,
+   __LINE__ );
+   return NULL;
+   }
ret->version = 0;
-   M_ASN1_New(ret->enc_algor, X509_ALGOR_new);
-   M_ASN1_New(ret->enc_pkey, M_ASN1_OCTET_STRING_new);
+   ret->enc_algor = X509_ALGOR_new();
+   if (ret->enc_algor == NULL)
+   return NULL;
+   ret->enc_pkey = M_ASN1_OCTET_STRING_new();
+   if (ret->enc_pkey == NULL)
+   return NULL;
ret->dec_pkey = NULL;
ret->key_length = 0;
ret->key_data = NULL;
@@ -121,7 +129,6 @@
memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH);
ret->references = 1;
return (ret);
-   M_ASN1_New_Error(ASN1_F_X509_PKEY_NEW);
 }

 void
Index: asn1_mac.h
===
RCS file: /cvs/src/lib/libssl/src/crypto/asn1/asn1_mac.h,v
retrieving revision 1.10
diff -u -r1.10 asn1_mac.h
--- asn1_mac.h  17 Apr 2014 13:37:48 -  1.10
+++ asn1_mac.h  22 Apr 2014 23:43:03 -
@@ -287,21 +287,6 @@
c.slen-=(c.p-c.q); \
}

-/* New macros */
-#define M_ASN1_New_Malloc(ret,type) \
-   if ((ret=(type *)malloc(sizeof(type))) == NULL) \
-   { c.line=__LINE__; goto err2; }
-
-#define M_ASN1_New(arg,func) \
-   if (((arg)=func()) == NULL) return(NULL)
-
-#define M_ASN1_New_Error(a) \
-/* err:ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \
-   return(NULL);*/ \
-   err2:   ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \
-   return(NULL)
-
-
 /* BIG UGLY WARNING!  This is so damn ugly I wanna puke.  Unfortunately,
some macros that use ASN1_const_CTX still insist on writing in the input
stream.  ARGH!  ARGH!  ARGH!  Let's get rid of this macro package.