Skip to contentSkip to conversation

a pair of things I found when debugging..

PATCH Robert Millan 2 participants 3 messages Jun 4, 2007

lore
Share & tools
lore
#0 lore raw

A pair of things I found when debugging powerpc issues. Let me know what you think (context comment follows).

Signature · 4 lines
Robert Millan

My spam trap is [email protected].  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.
util/biosdisk.c +2 -3
diff -ur grub2-1.95+20070520.old/util/biosdisk.c grub2-1.95+20070520/util/biosdisk.c
@@ -732,7 +732,7 @@
     int find_partition (grub_disk_t disk __attribute__ ((unused)),
 			const grub_partition_t partition)
       {
- 	struct grub_pc_partition *pcdata = 0;
+ 	struct grub_pc_partition *pcdata = NULL;
 
 	if (strcmp (partition->partmap->name, "pc_partition_map") == 0)
 	  pcdata = partition->data;
@@ -816,8 +816,7 @@
     if (dos_part < 0)
       {
 	grub_disk_close (disk);
-	grub_error (GRUB_ERR_BAD_DEVICE,
-		    "cannot find the partition of `%s'", os_dev);
+	grub_util_error ("cannot find the partition of `%s'", os_dev);
 	return 0;
       }
     
util/grub-probe.c +1 -1
diff -ur grub2-1.95+20070520.old/util/grub-probe.c grub2-1.95+20070520/util/grub-probe.c
@@ -81,7 +81,7 @@
 probe (const char *path)
 {
   char *device_name;
-  char *drive_name = 0;
+  char *drive_name = NULL;
   grub_device_t dev;
   grub_fs_t fs;
   
#1 lore raw

util/biosdisk.c

Quoted 7 lines · Robert Millan
util/biosdisk.c +2 -2
- 	struct grub_pc_partition *pcdata = 0;
+ 	struct grub_pc_partition *pcdata = NULL;
 
[...]
 
-  char *drive_name = 0;
+  char *drive_name = NULL;

I generaly find that NULL makes it clearer for pointers, do you have a preference for 0 on these?

util/biosdisk.c line 820

Quoted 8 lines
util/biosdisk.c +1 -2
@@ -816,8 +816,7 @@
     if (dos_part < 0)
       {
 	grub_disk_close (disk);
-	grub_error (GRUB_ERR_BAD_DEVICE,
-		    "cannot find the partition of `%s'", os_dev);
+	grub_util_error ("cannot find the partition of `%s'", os_dev);
 	return 0;

Not sure what I'm missing, but these grub_error calls seem to be pretty useless. This one in particular was the culprit to one of the powerpc problems I just fixed, and I had to replace it with grub_util_error() to find out.

Signature · 4 lines
Robert Millan

My spam trap is [email protected].  Note: this address is only intended
for spam harvesters.  Writing to it will get you added to my black list.
#2 lore raw

At Mon, 4 Jun 2007 21:03:11 +0200,

Quoted 5 lines · Robert Millan
Quoted 3 lines · Robert Millan
util/biosdisk.c +1 -1
- 	struct grub_pc_partition *pcdata = 0;
+ 	struct grub_pc_partition *pcdata = NULL;
Quoted 7 lines

util/grub-probe.c line 84

Quoted 4 lines

[...]

util/grub-probe.c +1 -1
-  char *drive_name = 0;
+  char *drive_name = NULL;

I generaly find that NULL makes it clearer for pointers, do you have a preference for 0 on these?

I agree.

Quoted 5 lines
Quoted 5 lines
util/biosdisk.c +0 -1
@@ -816,8 +816,7 @@
     if (dos_part < 0)
       {
 	grub_disk_close (disk);
-	grub_error (GRUB_ERR_BAD_DEVICE,
Quoted 8 lines

util/biosdisk.c line 820

Quoted 3 lines
util/biosdisk.c +1 -1
-		    "cannot find the partition of `%s'", os_dev);
+	grub_util_error ("cannot find the partition of `%s'", os_dev);
 	return 0;

Not sure what I'm missing, but these grub_error calls seem to be pretty useless. This one in particular was the culprit to one of the powerpc problems I just fixed, and I had to replace it with grub_util_error() to find out.

Yes, as I already wrote in relation to the RAID thing, handling of errors and warnings need some care.

Jeroen Dekkers