Re: Less syslog errors

On Sat, 2004-11-13 at 15:14 +0100, Tom Parker wrote:

> -               if ((iter = nm_ap_list_iter_new (old_ap_list)))
> +               if (old_ap_list && (iter = nm_ap_list_iter_new (old_ap_list)))

Fundamentally, it seems that the NetworkManagerAPList is inconsistent in
that some functions can return NULL (e.g. nm_ap_list_combine), but NULL
is not a valid argument for other nm_ap_list functions, like
nm_ap_list_iter_new.  Rather than propagating NULL handing logic to
every caller, it seems cleaner to me to accept NULL as a valid argument
inside the ap_list functions as appropriate.  As it turned out, this is
basically as easy as making nm_ap_list_iter_new (NULL) just return NULL,
and removing a bunch of assertions that list arguments aren't NULL,
since they just call nm_ap_list_iter_new.

It doesn't make sense for all of them though (like nm_ap_list_lock), so
this is kind of a kludge.  It is probably better to ensure that we
always use the empty AP list instead of NULL, but just using NULL seems
safer to me for now.  I did some grepping and got a sense of where we
were able to handle NULL, and it looks like this patch will work

I haven't applied it, since I'm still learning the code myself.  Dan,
what do you think?

> The third one is driving me nuts. The assertion is the "dest!=NULL" at 
> the top of nm_ap_list_copy_properties (line 426 of 
> NetworkManagerAPList.c), which is being called by 
> nm_device_do_normal_scan at roughly line 2445 of NetworkManagerDevice.c. 

The above patch should fix this too.  Let me know if it works for you.

cvs server: Diffing .
cvs server: Diffing dispatcher-daemon
cvs server: Diffing docs
cvs server: Diffing examples
cvs server: Diffing examples/python
cvs server: Diffing examples/python/systray
cvs server: Diffing info-daemon
cvs server: Diffing initscript
cvs server: Diffing initscript/Debian
cvs server: Diffing initscript/Gentoo
cvs server: Diffing initscript/RedHat
cvs server: Diffing initscript/Slackware
cvs server: Diffing panel-applet
cvs server: Diffing panel-applet/icons
cvs server: Diffing po
cvs server: Diffing src
Index: src/NetworkManagerAPList.c
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerAPList.c,v
retrieving revision 1.20
diff -u -d -r1.20 NetworkManagerAPList.c
--- src/NetworkManagerAPList.c	27 Oct 2004 19:02:07 -0000	1.20
+++ src/NetworkManagerAPList.c	13 Nov 2004 19:31:51 -0000
@@ -428,9 +428,6 @@
 	NMAPListIter	*iter;
 	NMAccessPoint	*dest_ap;
-	g_return_if_fail (dest != NULL);
-	g_return_if_fail (source != NULL);
 	if ((iter = nm_ap_list_iter_new (dest)))
 		while ((dest_ap = nm_ap_list_iter_next (iter)))
@@ -462,9 +459,6 @@
 	NMAPListIter	*iter;
 	NMAccessPoint	*dest_ap;
-	g_return_if_fail (dest != NULL);
-	g_return_if_fail (source != NULL);
 	if ((iter = nm_ap_list_iter_new (dest)))
 		while ((dest_ap = nm_ap_list_iter_next (iter)))
@@ -584,7 +578,8 @@
 	NMAPListIter	*iter;
-	g_return_val_if_fail (list != NULL, NULL);
+	if (list == NULL)
+		return (NULL);
 	if (!(iter = g_new0 (NMAPListIter, 1)))
 		return (NULL);
@@ -652,7 +647,6 @@
 	NMAPListIter	*iter;
 	int			 i = 0;
-	g_return_if_fail (list != NULL);
 	g_return_if_fail (name != NULL);
 	if (!(iter = nm_ap_list_iter_new (list)))
Index: src/NetworkManagerDevice.c
RCS file: /cvs/gnome/NetworkManager/src/NetworkManagerDevice.c,v
retrieving revision 1.61
diff -u -d -r1.61 NetworkManagerDevice.c
--- src/NetworkManagerDevice.c	11 Nov 2004 02:24:04 -0000	1.61
+++ src/NetworkManagerDevice.c	13 Nov 2004 19:31:51 -0000
@@ -2474,7 +2474,8 @@
 			nm_ap_list_iter_free (iter);
-		nm_ap_list_unref (old_ap_list);
+		if (old_ap_list)
+			nm_ap_list_unref (old_ap_list);
 		/* Generate the "old" list from the 3rd and 4th oldest scans we've done */
 		old_ap_list = nm_ap_list_combine (dev->options.wireless.cached_ap_list3, earliest_scan);
cvs server: Diffing src/backends
cvs server: Diffing test

Attachment: signature.asc
Description: This is a digitally signed message part

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]