svn commit: trunk/busybox: libbb procps

vda at busybox.net vda at busybox.net
Wed Sep 27 14:17:32 UTC 2006


Author: vda
Date: 2006-09-27 07:17:31 -0700 (Wed, 27 Sep 2006)
New Revision: 16233

Log:
process utilities related style cleanup


Modified:
   trunk/busybox/libbb/find_pid_by_name.c
   trunk/busybox/procps/ps.c


Changeset:
Modified: trunk/busybox/libbb/find_pid_by_name.c
===================================================================
--- trunk/busybox/libbb/find_pid_by_name.c	2006-09-27 14:14:51 UTC (rev 16232)
+++ trunk/busybox/libbb/find_pid_by_name.c	2006-09-27 14:17:31 UTC (rev 16233)
@@ -23,18 +23,17 @@
  *  Returns a list of all matching PIDs
  *  It is the caller's duty to free the returned pidlist.
  */
-long* find_pid_by_name( const char* pidName)
+long* find_pid_by_name(const char* pidName)
 {
 	long* pidList;
-	int i=0;
-	procps_status_t * p;
+	int i = 0;
+	procps_status_t* p;
 
 	pidList = xmalloc(sizeof(long));
-	while ((p = procps_scan(0)) != 0)
-	{
+	while ((p = procps_scan(0)) != 0) {
 		if (strncmp(p->short_cmd, pidName, COMM_LEN-1) == 0) {
-			pidList=xrealloc( pidList, sizeof(long) * (i+2));
-			pidList[i++]=p->pid;
+			pidList = xrealloc( pidList, sizeof(long) * (i+2));
+			pidList[i++] = p->pid;
 		}
 	}
 
@@ -44,9 +43,9 @@
 
 long *pidlist_reverse(long *pidList)
 {
-	int i=0;
+	int i = 0;
 	while (pidList[i] > 0 && ++i);
-	if ( i-- > 0) {
+	if (i-- > 0) {
 		long k;
 		int j;
 		for (j = 0; i > j; i--, j++) {

Modified: trunk/busybox/procps/ps.c
===================================================================
--- trunk/busybox/procps/ps.c	2006-09-27 14:14:51 UTC (rev 16232)
+++ trunk/busybox/procps/ps.c	2006-09-27 14:17:31 UTC (rev 16233)
@@ -57,41 +57,40 @@
 
 #if ENABLE_SELINUX
 	if (use_selinux)
-	  printf("  PID Context                          Stat Command\n");
+		puts("  PID Context                          Stat Command");
 	else
 #endif
-	  printf("  PID  Uid     VmSize Stat Command\n");
+		puts("  PID  Uid     VmSize Stat Command");
 
 	while ((p = procps_scan(1)) != 0)  {
 		char *namecmd = p->cmd;
 #if ENABLE_SELINUX
-		if (use_selinux)
-		  {
+		if (use_selinux) {
 			char sbuf[128];
 			len = sizeof(sbuf);
 
 			if (is_selinux_enabled()) {
-			  if (getpidcon(p->pid,&sid)<0)
-			    sid=NULL;
+				if (getpidcon(p->pid,&sid) < 0)
+					sid = NULL;
 			}
 
 			if (sid) {
-			  /*  I assume sid initilized with NULL  */
-			  len = strlen(sid)+1;
-			  safe_strncpy(sbuf, sid, len);
-			  freecon(sid);
-			  sid=NULL;
-			}else {
-			  safe_strncpy(sbuf, "unknown",7);
+				/*  I assume sid initilized with NULL  */
+				len = strlen(sid)+1;
+				safe_strncpy(sbuf, sid, len);
+				freecon(sid);
+				sid = NULL;
+			} else {
+				safe_strncpy(sbuf, "unknown", 7);
 			}
 			len = printf("%5d %-32s %s ", p->pid, sbuf, p->state);
 		}
 		else
 #endif
-		  if(p->rss == 0)
-		    len = printf("%5d %-8s        %s ", p->pid, p->user, p->state);
-		  else
-		    len = printf("%5d %-8s %6ld %s ", p->pid, p->user, p->rss, p->state);
+			if(p->rss == 0)
+				len = printf("%5d %-8s        %s ", p->pid, p->user, p->state);
+			else
+				len = printf("%5d %-8s %6ld %s ", p->pid, p->user, p->rss, p->state);
 
 		i = terminal_width-len;
 




More information about the busybox-cvs mailing list