[RESEND][PATCH] code cleanup

Jouni Malinen jkmaline
Sun Aug 21 18:12:53 PDT 2005


On Wed, Aug 17, 2005 at 09:47:57AM +0200, Leonardo Maccari wrote:

> I resend the patch, waiting for some feedback on it.

Sorry about the delay in replying to this. Adding patches to bugzilla is
indeed a good idea if I happen to not reply within reasonable time..

> +++ wpa_supplicant-0.4.3-dev/wpa.h	2005-07-11 15:00:36.000000000 +0200

> +typedef enum {
> +	WPA_DISCONNECTED, WPA_SCANNING, WPA_ASSOCIATING,
> +	WPA_ASSOCIATED, WPA_4WAY_HANDSHAKE, WPA_GROUP_HANDSHAKE,
> +	WPA_COMPLETED
> +} wpa_states;

These do not really belong to wpa.h, but maybe it is the easiest
location to have this enum defined at least for now.

> +++ wpa_supplicant-0.4.3-dev/wpa_i.h	2005-07-11 15:09:46.000000000 +0200

> +struct wpa_sm_interface {
> +	void (*set_state)(void *ctx, wpa_states state);

> +struct preauth_interface {
> +	wpa_states (*get_state)(void * ctx);

> +	struct wpa_sm_interface *wpa_sm_i; /* structure with pointers to
> +										  callback functions to interface
> +										  wpa state machine code*/ 
> +	struct preauth_interface *preauth_i; /* structure with pointers to
> +										  callback functions to interface
> +										  preauth code*/

Is there any particular reason for separating wpa_sm_i and preauth_i? If
not, I would prefer to just keep one structure for callback functions.

> +++ wpa_supplicant-0.4.3-dev/wpa_supplicant.c	2005-07-12 10:46:24.000000000 +0200

> +struct wpa_sm_interface {
> +	void (*set_state)(struct wpa_supplicant *wpa_s, wpa_states state);

??? This structure was already defined in wpa_i.h. There must not be
more than one place where this is defined and it looks like that the
correct place would be in wpa.h.

> +	wpa_sm_i = malloc(sizeof(struct wpa_sm_interface));
> +	preauth_i = malloc(sizeof(struct preauth_interface));
> +	
> +	export_wpa_interface(wpa_sm_i);
> +	export_preauth_interface(preauth_i);

Must check whether malloc() failed before using the pointer.

-- 
Jouni Malinen                                            PGP id EFC895FA




More information about the Hostap mailing list