File isapnp-codecleanup.diff of Package isapnp

--- include/isapnp/callbacks.h
+++ include/isapnp/callbacks.h
@@ -106,7 +106,7 @@
 /*                                                                          */
 /****************************************************************************/
 
-extern char *st_error_messages[];
+extern const char *st_error_messages[];
 
 extern fatal_error     normal_fatal_error_callback;
 
--- include/isapnp/resource.h
+++ include/isapnp/resource.h
@@ -58,7 +58,7 @@
 
 
 extern int
-allocate_resource(char tag, unsigned long start, unsigned long len, char *source);
+allocate_resource(char tag, unsigned long start, unsigned long len, const char *source);
 				/* Returns 1 on successful reservation. */
 
 void
--- src/callbacks.c
+++ src/callbacks.c
@@ -51,6 +51,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
+#include <stdlib.h>
 
 /****************************************************************************/
 
@@ -91,7 +92,7 @@
 /* Callbacks needed by the libisapnp procedures                             */
 /****************************************************************************/
 
-char *st_error_messages[] = {
+const char * st_error_messages[] = {
 #define ISAPNP_ERR_CODE(code,msg) msg,
 #include <isapnp/errcodes.h>
 };
--- src/cardinfo.c
+++ src/cardinfo.c
@@ -199,7 +199,7 @@
   }
 
   for (l_index = 0, l_card = -1;
-       l_index < in_results_p->m_resource_count; l_index++) {
+       (int)l_index < in_results_p->m_resource_count; l_index++) {
 
 #ifdef DEBUG
     printf("find_resources_for_card: iteration %d (card %d) res.type 0x%02x\n",
--- src/pnp-select.c
+++ src/pnp-select.c
@@ -33,8 +33,8 @@
         int min_priority;
 	int best_priority;
 	int best_index;
-	int i;
-        if (res->value == -1) {
+	unsigned long i;
+        if (res->value == -1UL) {
 	    min_priority = -1;
         }
 	else {
--- src/pnpdump_main.c
+++ src/pnpdump_main.c
@@ -156,7 +156,7 @@
 
 
 static void
-banner(FILE *fp, char *prefix)
+banner(FILE *fp, const char *prefix)
 {
 	fprintf(fp, 
 			"%s%s\n"
@@ -489,7 +489,7 @@
 }
 
 static void
-lengtherror(struct resource *res, char *msg)
+lengtherror(struct resource *res, const char *msg)
 {
 	int tag = res->tag;
 	int len = res->len;
@@ -617,7 +617,7 @@
 	case LogDevId_TAG:
 		{
 			int reg;
-			static char *regfns[8] =
+			static const char *regfns[8] =
 			{"Device capable of taking part in boot process",
 			 "Device supports I/O range check register",
 			 "Device supports reserved register @ 0x32",
@@ -839,7 +839,7 @@
 		}
 	case EndDep_TAG:
 		{
-			int i;
+			unsigned int i;
 			if (len > 0)
 			{
 				lengtherror(res, "EndDep_TAG");
--- src/resource.c
+++ src/resource.c
@@ -12,11 +12,13 @@
    alloc_in_range_list() reordered to handle source name by P.Fox
 */
 
+#define _GNU_SOURCE /* needed for declaration of getdelim */
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
-static char Id[] __attribute__((unused)) = "$Id: resource.c,v 0.10 2001/04/30 21:50:29 fox Exp $";
+static char Id[] __attribute__((used)) = "$Id: resource.c,v 0.10 2001/04/30 21:50:29 fox Exp $";
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -24,6 +26,8 @@
 #include <string.h>
 
 #ifdef ENABLE_PCI
+#include <linux/types.h>
+typedef unsigned long kernel_ulong_t;
 #include <linux/pci.h>
 #endif
 
@@ -63,7 +67,7 @@
 }
 
 static int
-alloc_in_range_list (unsigned long start, unsigned long end, struct range_list **list, char *source)
+alloc_in_range_list (unsigned long start, unsigned long end, struct range_list **list, const char *source)
 {
 
   	struct range_list *new;
@@ -174,7 +178,7 @@
 
 	new->start 	= start;
 	new->end 	= end;
-	new->source = source;
+	new->source = (char *)source;
 
 	/* If we have a predecessor, tag us on */
 
@@ -232,7 +236,7 @@
     }
 }
 
-int print_irq() {
+int print_irq(void) {
 	st_progress_report_callback("# IRQ\n");
 	return _print_list(tag_range_lists[0]);
 }
@@ -243,7 +247,7 @@
 }
 
 int
-allocate_resource(char tag, unsigned long start, unsigned long len, char *source) {
+allocate_resource(char tag, unsigned long start, unsigned long len, const char *source) {
     return alloc_in_range_list(start, start + len,
 							   &tag_range_lists[tag_to_index(tag)], source);
 }
@@ -284,8 +288,8 @@
 
 void allocate_pci_resources( void )
 {
-   char *line = 0;
-   int lineMax = 0;
+   char *line = NULL;
+   size_t lineMax = 0;
 
    FILE *fp = fopen( "/proc/bus/pci/devices", "rt" );
    if( !fp )
openSUSE Build Service is sponsored by