PERFORCE change 83120 for review

Victor Cruceru soc-victor at FreeBSD.org
Sun Sep 4 15:20:00 PDT 2005


http://perforce.freebsd.org/chv.cgi?CH=83120

Change 83120 by soc-victor at soc-victor_82.76.158.176 on 2005/09/04 22:19:33

	Cleanup again (possible compiler portability issue)

Affected files ...

.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c#11 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c#12 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c#7 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_network_tbl.c#6 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_printer_tbl.c#6 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c#11 edit

Differences ...

==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c#11 (text+ko) ====

@@ -49,6 +49,13 @@
 struct hrDeviceTblEntry *
 hrDeviceTblEntry_find_by_index(int32_t idx);
 
+/*some constant variables*/
+static 
+const struct asn_oid OIDX_hrDeviceProcessor_c = OIDX_hrDeviceProcessor;	
+
+static 
+const struct asn_oid OIDX_hrDeviceOther_c = OIDX_hrDeviceOther;
+
 static
 struct hrDeviceTblEntry* 
 hrDeviceTblEntry_create( const struct devinfo_dev *dev_p) {
@@ -199,11 +206,11 @@
 		
 	if (strncmp(dev_p->dd_name, "cpu", strlen("cpu")) == 0 && 
 	    strstr(dev_p->dd_location, ".CPU") != NULL) {
-		*out_type_p = (struct asn_oid)OIDX_hrDeviceProcessor;
+		*out_type_p = OIDX_hrDeviceProcessor_c;
 		return;
 	} 	
 	
-	*out_type_p = (struct asn_oid)OIDX_hrDeviceOther; /*FIX ME*/
+	*out_type_p = OIDX_hrDeviceOther_c; /*FIX ME*/
 }
 
 static

==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c#12 (text+ko) ====

@@ -48,6 +48,11 @@
 #include <sys/mdioctl.h>
 #include <paths.h>
 
+
+/*some constant variables*/
+static 
+const struct asn_oid OIDX_hrDeviceDiskStorage_c = OIDX_hrDeviceDiskStorage;
+
 extern
 struct hrDeviceTblEntry *
 hrDeviceTblEntry_find_by_index(int32_t idx);
@@ -315,7 +320,7 @@
 					continue;
 				}	
 
-				entry->type = (struct asn_oid)OIDX_hrDeviceDiskStorage;
+				entry->type = OIDX_hrDeviceDiskStorage_c;
 				entry->id = oid_zeroDotZero; /*unknown id - FIX ME*/
 				entry->status = (int32_t)DS_RUNNING;
 				entry->errors = 0; /*FIX ME*/
@@ -429,7 +434,7 @@
 					continue;
 				}	
 
-				entry->type = (struct asn_oid)OIDX_hrDeviceDiskStorage;
+				entry->type = OIDX_hrDeviceDiskStorage_c;
 				entry->id = oid_zeroDotZero; /*unknown id - FIX ME*/
 				entry->status = DR_RUNNING;
 				entry->errors = 0; /*FIX ME*/
@@ -547,7 +552,7 @@
 				continue;
 			}	
 
-			entry->type = (struct asn_oid)OIDX_hrDeviceDiskStorage;
+			entry->type = OIDX_hrDeviceDiskStorage_c;
 			entry->id = oid_zeroDotZero; /*unknown id - FIX ME*/
 			entry->status = (int32_t)DS_RUNNING;
 			entry->errors = 0; /*FIX ME*/
@@ -659,7 +664,7 @@
 			 disk_device ));
 			entry =  hrDeviceTblEntry_create(disk);
 			entry->flags |= HR_DEVICE_IMMUTABLE;
-			entry->type = (struct asn_oid)OIDX_hrDeviceDiskStorage;
+			entry->type = OIDX_hrDeviceDiskStorage_c;
 			entry->id = oid_zeroDotZero; /*unknown id - FIX ME*/
 			entry->status = (int32_t)DS_RUNNING;
 			entry->errors = 0; /*FIX ME*/
@@ -670,7 +675,7 @@
 			HR_DPRINTF((stderr,
 			 "hrDiskStorageTable; disk %s already in hrDeviceTable\n",
 			 disk_device ));
- 			entry->type = (struct asn_oid)OIDX_hrDeviceDiskStorage;
+ 			entry->type = OIDX_hrDeviceDiskStorage_c;
 			entry->flags |= HR_DEVICE_IMMUTABLE;
 		}
 		/*Then check hrDiskStorage table for this device*/

==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c#7 (text+ko) ====

@@ -40,6 +40,37 @@
 #include <string.h>
 #include <err.h>
 
+/*some constant variables*/
+static 
+const struct asn_oid OIDX_hrFSBerkeleyFFS_c = OIDX_hrFSBerkeleyFFS;
+
+static 
+const struct asn_oid OIDX_hrFSiso9660_c = OIDX_hrFSiso9660;
+
+static 
+const struct asn_oid OIDX_hrFSNFS_c = OIDX_hrFSNFS;
+
+static 
+const struct asn_oid OIDX_hrFSLinuxExt2_c = OIDX_hrFSLinuxExt2;
+
+static 
+const struct asn_oid OIDX_hrFSOther_c = OIDX_hrFSOther;
+
+static 
+const struct asn_oid OIDX_hrFSFAT32_c = OIDX_hrFSFAT32;
+
+static 
+const struct asn_oid OIDX_hrFSNTFS_c = OIDX_hrFSNTFS;
+
+static 
+const struct asn_oid OIDX_hrFSNetware_c = OIDX_hrFSNetware;
+
+static 
+const struct asn_oid OIDX_hrFSHPFS_c = OIDX_hrFSHPFS;
+
+static 
+const struct asn_oid OIDX_hrFSUnknown_c = OIDX_hrFSUnknown;
+
 extern 
 void 
 handle_partition_fs_index(const char *name, int32_t fs_idx);
@@ -222,60 +253,56 @@
 	assert(out_type_p != NULL);
 
 	if(strncmp( fs_p->f_fstypename, "ufs", strlen("ufs") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSBerkeleyFFS;
+		*out_type_p = OIDX_hrFSBerkeleyFFS_c;
 		return;
 	}
 	if(strncmp( fs_p->f_fstypename, "cd9660", strlen("cd9660") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSiso9660;
+		*out_type_p = OIDX_hrFSiso9660_c;
 		return;
 	}
 
 	if(strncmp( fs_p->f_fstypename, "nfs", strlen("nfs") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSNFS;
+		*out_type_p = OIDX_hrFSNFS_c;
 		return;
 	}
 
 	if(strncmp( fs_p->f_fstypename, "ext2fs", strlen("ext2fs") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSLinuxExt2;
+		*out_type_p = OIDX_hrFSLinuxExt2_c;
 		return;
 	}
 
 	if(strncmp( fs_p->f_fstypename, "procfs", strlen("procfs") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSOther;
+		*out_type_p = OIDX_hrFSOther_c;
 		return;
 	}
 
 	if(strncmp( fs_p->f_fstypename, "devfs", strlen("devfs") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSOther;
+		*out_type_p = OIDX_hrFSOther_c;
 		return;
 	}
 		
 	if(strncmp( fs_p->f_fstypename, "msdosfs", strlen("msdosfs") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSFAT32;
+		*out_type_p = OIDX_hrFSFAT32_c;
 		return;
 	}
 			
 	if(strncmp( fs_p->f_fstypename, "ntfs", strlen("ntfs") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSNTFS;
+		*out_type_p = OIDX_hrFSNTFS_c;
 		return;
 	}
 
 	if(strncmp( fs_p->f_fstypename, "nwfs", strlen("nwfs") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSNetware;
+		*out_type_p = OIDX_hrFSNetware_c;
 		return;
 	}
 
 	if(strncmp( fs_p->f_fstypename, "hpfs", strlen("hpfs") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSHPFS;
+		*out_type_p = OIDX_hrFSHPFS_c;
 		return;
 	}
 
-	if(strncmp( fs_p->f_fstypename, "hpfs", strlen("hpfs") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrFSHPFS;
-		return;
-	}
 																																																																																																								
-	*out_type_p = (struct asn_oid)OIDX_hrFSUnknown;
+	*out_type_p = OIDX_hrFSUnknown_c;
 }
 
 void 

==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_network_tbl.c#6 (text+ko) ====

@@ -87,6 +87,10 @@
 #include <arpa/inet.h>
 #include <ctype.h>
 
+
+static 
+const struct asn_oid OIDX_hrDeviceNetwork_c = OIDX_hrDeviceNetwork;
+
 extern
 struct hrDeviceTblEntry*
 hrDeviceTblEntry_find_by_name(const char *dev_name);
@@ -323,7 +327,7 @@
 				continue;
 			}
 			dev_entry->flags |= HR_DEVICE_IMMUTABLE;
-			dev_entry->type = (struct asn_oid)OIDX_hrDeviceNetwork;
+			dev_entry->type = OIDX_hrDeviceNetwork_c;
 			dev_entry->id = oid_zeroDotZero; /*unknown id - FIX ME*/
 			dev_entry->status = (int32_t)DS_RUNNING;
 			dev_entry->errors = 0; /*FIX ME*/
@@ -335,7 +339,7 @@
 			HR_DPRINTF((stderr,
 			"hrNetworkTable: %s already in hrDeviceTable\n",
 			ifptr->ifr_name ));
-			dev_entry->type = (struct asn_oid)OIDX_hrDeviceNetwork;
+			dev_entry->type = OIDX_hrDeviceNetwork_c;
 			dev_entry->flags |= HR_DEVICE_IMMUTABLE;
 		}
 	

==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_printer_tbl.c#6 (text+ko) ====

@@ -80,7 +80,10 @@
 #include <err.h>
 #include <sys/stat.h>
 
+static 
+const struct asn_oid OIDX_hrDevicePrinter_c = OIDX_hrDevicePrinter;
 
+
 #define	_PATH_PRINTCAP		"/etc/printcap"
 #define	_PATH_DEFDEVLP		"/dev/lp"
 #define	_PATH_DEFSPOOL		"/var/spool/output/lpd"
@@ -753,7 +756,7 @@
 			return;
 		}
 		dev_entry->flags |= HR_DEVICE_IMMUTABLE;
-		dev_entry->type = (struct asn_oid)OIDX_hrDevicePrinter;
+		dev_entry->type = OIDX_hrDevicePrinter_c;
 		dev_entry->id = oid_zeroDotZero; /*unknown id - FIX ME*/
 		dev_entry->status = (int32_t)DS_RUNNING;
 		dev_entry->errors = 0; /*FIX ME*/
@@ -766,7 +769,7 @@
 		HR_DPRINTF((stderr,
 		"hrPrinterTable: %s already in hrDeviceTable\n",
 		pp->lp ));
-		dev_entry->type = (struct asn_oid)OIDX_hrDevicePrinter;
+		dev_entry->type = OIDX_hrDevicePrinter_c;
 		dev_entry->flags |= HR_DEVICE_IMMUTABLE;
 	}
 

==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c#11 (text+ko) ====

@@ -42,9 +42,28 @@
 #include <vm/vm_param.h>
 #include <paths.h>
 
+static 
+const struct asn_oid OIDX_hrStorageOther_c = OIDX_hrStorageOther;
+
+static 
+const struct asn_oid OIDX_hrStorageFloppyDisk_c = OIDX_hrStorageFloppyDisk;
+
+static 
+const struct asn_oid OIDX_hrStorageCompactDisc_c = OIDX_hrStorageCompactDisc;
+
+static 
+const struct asn_oid OIDX_hrStorageFixedDisk_c = OIDX_hrStorageFixedDisk;
+
+static 
+const struct asn_oid OIDX_hrStorageRam_c = OIDX_hrStorageRam;
 
+static 
+const struct asn_oid OIDX_hrStorageVirtualMemory_c = OIDX_hrStorageVirtualMemory;
 
+static 
+const struct asn_oid OIDX_hrStorageNetworkDisk_c = OIDX_hrStorageNetworkDisk;
 
+
 static
 struct hrStorageTblEntry* 
 hrStorageTblEntry_create( const char *name ) {
@@ -83,9 +102,13 @@
 			sizeof(map->a_name) - 1);
 		map->entry_p = entry;
 		STAILQ_INSERT_TAIL(&hrState_g.storage_name_map, map, link);
-		HR_DPRINTF((stderr, "%s  added into hrStorageMap at index=%d\n ", name, map->hrIndex));
+		HR_DPRINTF((stderr, "%s  added into hrStorageMap at index=%d\n ", 
+		  name, 
+		  map->hrIndex));
 	} else {
-		HR_DPRINTF((stderr, "%s  exists in hrStorageMap index=%d\n ", name, map->hrIndex));
+		HR_DPRINTF((stderr, "%s  exists in hrStorageMap index=%d\n ", 
+		  name, 
+		  map->hrIndex));
 	}
 	
 	entry->index = map->hrIndex;
@@ -152,7 +175,9 @@
 	int page_size_bytes;
 	struct hrStorageTblEntry *entry = NULL;
 	if ( sysctl(mib, 2, &hrState_g.mem_stats, &len, NULL, 0) < 0 ) {
-		syslog(LOG_ERR, "hrStoragetable: %s: sysctl( { CTL_VM, VM_METER } ) failed: %m ", __func__ );	
+		syslog(LOG_ERR,
+		  "hrStoragetable: %s: sysctl( { CTL_VM, VM_METER } ) failed: %m ", 
+		  __func__ );	
 		assert(0);
 		return;
 	}
@@ -170,7 +195,7 @@
 	if ( entry == NULL) return; /*I'm out of luck now, maybe next time*/
 	
 	entry->flags |= HR_STORAGE_FOUND;
-	entry->type = (struct asn_oid)OIDX_hrStorageRam;
+	entry->type = OIDX_hrStorageRam_c;
 	entry->allocationUnits = page_size_bytes;
 	entry->size = hrState_g.mem_stats.t_rm;
 	entry->used = hrState_g.mem_stats.t_arm; /*ACTIVE is not USED - FIX ME */
@@ -187,7 +212,7 @@
 	if ( entry == NULL) return; /*I'm out of luck now, maybe next time*/
 	
 	entry->flags |= HR_STORAGE_FOUND;
-	entry->type = (struct asn_oid)OIDX_hrStorageRam;
+	entry->type = OIDX_hrStorageRam_c;
 	entry->allocationUnits = page_size_bytes;
 	entry->size = hrState_g.mem_stats.t_rmshr;
 	entry->used = hrState_g.mem_stats.t_armshr; /*ACTIVE is not USED - FIX ME */
@@ -245,7 +270,7 @@
 		entry = hrStorageTblEntry_find_by_name(swap_w_prefix);
 		if (entry != NULL) {
 			entry->flags |= HR_STORAGE_FOUND;
-			entry->type = (struct asn_oid)OIDX_hrStorageVirtualMemory;
+			entry->type = OIDX_hrStorageVirtualMemory_c;
 			entry->allocationUnits = getpagesize();
 			entry->size = hrState_g.swap_devs[len].ksw_total;
 			entry->used = hrState_g.swap_devs[len].ksw_used;
@@ -254,7 +279,7 @@
 		}
 		if ((entry = hrStorageTblEntry_create(swap_w_prefix)) != NULL) {
 			entry->flags |= HR_STORAGE_FOUND;
-			entry->type = (struct asn_oid)OIDX_hrStorageVirtualMemory;
+			entry->type = OIDX_hrStorageVirtualMemory_c;
 			entry->allocationUnits = getpagesize();
 			entry->size = hrState_g.swap_devs[len].ksw_total;			
 			entry->used = hrState_g.swap_devs[len].ksw_used;
@@ -276,26 +301,27 @@
 void hrStrorage_getType_v(const struct statfs *fs_p, struct asn_oid *out_type_p) {
 	assert(fs_p != NULL);
 	assert(out_type_p != NULL);
+	
 	if ( !(fs_p->f_flags &  MNT_LOCAL) ) {
-		*out_type_p = (struct asn_oid)OIDX_hrStorageNetworkDisk;
+		*out_type_p = OIDX_hrStorageNetworkDisk_c;
 		return;
 	}
 	
 	if ( strncmp (fs_p->f_fstypename, "procfs", MFSNAMELEN ) == 0 || 
 	     strncmp (fs_p->f_fstypename, "devfs", MFSNAMELEN ) == 0  ) {
-		*out_type_p = (struct asn_oid)OIDX_hrStorageOther;
+		*out_type_p = OIDX_hrStorageOther_c;
 		return;
 	
 	}
 	if ( strncmp (fs_p->f_mntfromname, "/dev/fd", strlen("/dev/fd") ) == 0  || 
 	     strncmp (fs_p->f_mntfromname, "/dev/afd", strlen("/dev/afd") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrStorageFloppyDisk; 
+		*out_type_p = OIDX_hrStorageFloppyDisk_c; 
 		return;
 	}
 
 	if ( strncmp (fs_p->f_mntfromname, "/dev/acd", strlen("/dev/acd") ) == 0  || 
 	     strncmp (fs_p->f_mntfromname, "/dev/cd", strlen("/dev/cd") ) == 0) {
-		*out_type_p = (struct asn_oid)OIDX_hrStorageCompactDisc; 
+		*out_type_p = OIDX_hrStorageCompactDisc_c; 
 		return;
 	}
 
@@ -303,12 +329,12 @@
 	if ( strncmp (fs_p->f_mntfromname, "/dev/ad", strlen("/dev/ad") ) == 0 ||
 	     strncmp (fs_p->f_mntfromname, "/dev/ar", strlen("/dev/ar") ) == 0 ||
 	     strncmp (fs_p->f_mntfromname, "/dev/da", strlen("/dev/da") ) == 0 ) {
-		*out_type_p = (struct asn_oid)OIDX_hrStorageFixedDisk; 
+		*out_type_p = OIDX_hrStorageFixedDisk_c; 
 		return;		
 	}
 
 		
-	*out_type_p = (struct asn_oid)OIDX_hrStorageOther; /*not known*/
+	*out_type_p = OIDX_hrStorageOther_c; /*not known*/
 	return;
 	
 }
@@ -547,7 +573,8 @@
 			return (SNMP_ERR_NOSUCHNAME);
 		}
 			
-		if ((entry = hrStorageTblEntry_find_by_index(value->var.subs[sub])) == NULL) {
+		if ((entry = hrStorageTblEntry_find_by_index(value->var.subs[sub]))
+			 == NULL) {
 			return (SNMP_ERR_NOSUCHNAME);
 		}
 		break;


More information about the p4-projects mailing list