summaryrefslogtreecommitdiff
path: root/extras/chassis_id/chassis_id.c
diff options
context:
space:
mode:
authorgreg@kroah.com <greg@kroah.com>2004-03-31 18:27:02 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:35:13 -0700
commit0bcdc8498cdeaaef37444d38f39a19ff9557914d (patch)
treeb3c02c9b1e1f06ac130cac34d3a4d357172651c6 /extras/chassis_id/chassis_id.c
parentfa5acd760db98d8f7ec810e44e8d4527b115e43c (diff)
[PATCH] clean up chassis_id coding style.
Diffstat (limited to 'extras/chassis_id/chassis_id.c')
-rw-r--r--extras/chassis_id/chassis_id.c152
1 files changed, 72 insertions, 80 deletions
diff --git a/extras/chassis_id/chassis_id.c b/extras/chassis_id/chassis_id.c
index 8f878b2c6e..857707eac7 100644
--- a/extras/chassis_id/chassis_id.c
+++ b/extras/chassis_id/chassis_id.c
@@ -1,19 +1,16 @@
-
- /* -*-c-*-:
- **
- ** (C) 2003 Intel Corporation
- ** Atul Sabharwal <atul.sabharwal@intel.com>
- **
- ** $Id: chassis_id.c,v 1.8 2004/03/22 23:33:10 atul Exp $
- **
- ** Distributed under the terms of the GNU Public License, v2.0 or
- ** later.
- **
- ** Many parts heavily based on test-skeleton.c, by Ulrich Drepper;
- ** with his permission, they have been re-licensed GPL, and his
- ** copyright still applies on them.
- **
- */
+/* -*-c-*-:
+ **
+ ** (C) 2003 Intel Corporation
+ ** Atul Sabharwal <atul.sabharwal@intel.com>
+ **
+ ** Distributed under the terms of the GNU Public License, v2.0 or
+ ** later.
+ **
+ ** Many parts heavily based on test-skeleton.c, by Ulrich Drepper;
+ ** with his permission, they have been re-licensed GPL, and his
+ ** copyright still applies on them
+ **
+ */
#include <stdio.h>
#include <stdlib.h>
@@ -25,88 +22,83 @@
int main(int argc, char **argv, char ** envp)
{
- int chassis_num, slot_num, retval, host_num;
- char disk_snum[255], devpath[255];
- char * ptr;
- int disk_index;
+ int chassis_num, slot_num, retval, host_num;
+ char disk_snum[255], devpath[255];
+ char *ptr;
+ int disk_index;
- syslog( LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", "starting chassis_id" );
+ syslog( LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", "starting chassis_id" );
#if 0
- ptr = (char *) getenv( "CHASSIS");
- if( ptr == NULL )
- return -ERROR_NO_CHASSIS;
+ ptr = getenv("CHASSIS");
+ if (ptr == NULL)
+ return -ERROR_NO_CHASSIS;
- sscanf(ptr, "%d", &chassis_num);
- #ifdef DEBUG
- syslog(LOG_PID| LOG_DAEMON| LOG_ERR, "Chassis %d", chassis_num);
- #endif
+ sscanf(ptr, "%d", &chassis_num);
+ #ifdef DEBUG
+ syslog(LOG_PID| LOG_DAEMON| LOG_ERR, "Chassis %d", chassis_num);
+ #endif
- ptr = (char *) getenv( "SLOT" );
- if( ptr== NULL )
- return -ERROR_NO_SLOT;
+ ptr = getenv("SLOT");
+ if (ptr== NULL)
+ return -ERROR_NO_SLOT;
- sscanf(ptr, "%d", &slot_num);
- #ifdef DEBUG
- syslog( LOG_PID|LOG_DAEMON| LOG_ERR, "Slot %d", slot_num);
- #endif
+ sscanf(ptr, "%d", &slot_num);
+ #ifdef DEBUG
+ syslog( LOG_PID|LOG_DAEMON| LOG_ERR, "Slot %d", slot_num);
+ #endif
#endif
- ptr = (char *) getenv( "DEVPATH");
- if( ptr == NULL )
- return -ERROR_NO_DEVPATH;
-
- sscanf(ptr, "%s", &devpath[0]);
- #ifdef DEBUG
- syslog( LOG_PID|LOG_DAEMON| LOG_ERR, "Devpath %s", devpath);
- #endif
-
- retval = table_init();
- if(retval < 0 )
- return -ERROR_BAD_TABLE;
-
- getserial_number( devpath, disk_snum);
-
-
- /* Now we open the provisioning table t find actual entry for the serial number*/
- disk_index = table_find_disk(disk_snum, &host_num, &chassis_num, &slot_num);
- if ( disk_index == -1 )
- {
- //typical provisioning error
- return -ERROR_NO_DISK;
- }
- else
- {
- table_select_disk( disk_index );
- }
- return 0;
+ ptr = getenv("DEVPATH");
+ if (ptr == NULL)
+ return -ERROR_NO_DEVPATH;
+
+ sscanf(ptr, "%s", &devpath[0]);
+ #ifdef DEBUG
+ syslog(LOG_PID|LOG_DAEMON| LOG_ERR, "Devpath %s", devpath);
+ #endif
+
+ retval = table_init();
+ if (retval < 0)
+ return -ERROR_BAD_TABLE;
+
+ getserial_number(devpath, disk_snum);
+
+ /* Now we open the provisioning table t find actual entry for the serial number*/
+ disk_index = table_find_disk(disk_snum, &host_num, &chassis_num, &slot_num);
+ if ( disk_index == -1 ) {
+ // typical provisioning error
+ return -ERROR_NO_DISK;
+ } else {
+ table_select_disk( disk_index );
+ }
+ return 0;
}
/* Run SCSI id to find serial number of the device */
int getserial_number( char * devpath, char * snumber )
{
- FILE *fp;
- char vendor [255], model[255], cmd[255];
- int retval;
-
- sprintf(cmd, "/sbin/scsi_id -s %s -p 0x80", devpath);
+ FILE *fp;
+ char vendor[255], model[255], cmd[255];
+ int retval;
- fp = popen( cmd, "r");
+ sprintf(cmd, "/sbin/scsi_id -s %s -p 0x80", devpath);
- if (fp == NULL)
- return -ERROR_BAD_SNUMBER;
+ fp = popen(cmd, "r");
- fscanf( fp, "%s %s %s", vendor, model, snumber);
- #ifdef DEBUG
- syslog( LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", snumber );
- #endif
+ if (fp == NULL)
+ return -ERROR_BAD_SNUMBER;
- retval = pclose(fp);
- if (retval == -1)
- return -ERROR_BAD_SNUMBER;
- else
- return NO_ERROR;
+ fscanf(fp, "%s %s %s", vendor, model, snumber);
+ #ifdef DEBUG
+ syslog(LOG_PID| LOG_DAEMON| LOG_ERR, "\n%s", snumber );
+ #endif
+ retval = pclose(fp);
+ if (retval == -1)
+ return -ERROR_BAD_SNUMBER;
+ else
+ return NO_ERROR;
}