src/hg/hgc/hgdpClick.c 1.8

1.8 2009/09/23 18:42:20 angie
Fixed compiler warnings from gcc 4.3.3, mostly about system calls whose return values weren't checked and non-literal format strings with no args.
Index: src/hg/hgc/hgdpClick.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgc/hgdpClick.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -b -B -U 4 -r1.7 -r1.8
--- src/hg/hgc/hgdpClick.c	4 May 2009 17:44:39 -0000	1.7
+++ src/hg/hgc/hgdpClick.c	23 Sep 2009 18:42:20 -0000	1.8
@@ -223,8 +223,15 @@
 if (rmdir(dirName) != 0)
     errAbort("rmdir failed for dir %s: %d", dirName, errno);
 }
 
+static void mustChdir(char *dir)
+/* Change directory to dir or die trying. */
+{
+if (chdir(dir) != 0)
+    errAbort("chdir(%s) failed: %s", dir, strerror(errno));
+}
+
 static void generateImgFiles(struct hgdpGeo *geo, char finalEpsFile[PATH_LEN],
 			     char finalPdfFile[PATH_LEN], char finalPngFile[PATH_LEN])
 /* Using the frequencies given in geo and the population latitude and longitude
  * given above, plot allele frequency pie charts for each population on a world map.
@@ -237,9 +244,9 @@
     errAbort("PATH_LEN (%d) is too short.", PATH_LEN);
 struct tempName dirTn;
 trashDirFile(&dirTn, "hgc", "hgdpGeo", "");
 makeDirs(dirTn.forCgi);
-chdir(dirTn.forCgi);
+mustChdir(dirTn.forCgi);
 char *realHome = getenv("HOME");
 setenv("HOME", ".", TRUE);
 
 // Make trash files with coordinate specs for pie charts and full circles:
@@ -307,9 +314,9 @@
 if (realHome == NULL)
     unsetenv("HOME");
 else
     setenv("HOME", realHome, TRUE);
-chdir(cwd);
+mustChdir(cwd);
 
 // Move the result files into place:
 char tmpPath[PATH_LEN];
 safef(tmpPath, sizeof(tmpPath), "%s/%s", dirTn.forCgi, epsFile);