if (i+1 >= argc) break;
strncpy(isofilename, argv[++i], MAXPATHLEN);
if (isofilename[0] != '/') {
- getcwd(path, MAXPATHLEN);
- if (strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
+ if (getcwd(path, MAXPATHLEN) != NULL &&
+ strlen(path) + strlen(isofilename) + 1 < MAXPATHLEN) {
strcat(path, "/");
strcat(path, isofilename);
strcpy(isofilename, path);
} else {
strncpy(file, argv[i], MAXPATHLEN);
if (file[0] != '/') {
- getcwd(path, MAXPATHLEN);
- if (strlen(path) + strlen(file) + 1 < MAXPATHLEN) {
+ if (getcwd(path, MAXPATHLEN) != NULL &&
+ strlen(path) + strlen(file) + 1 < MAXPATHLEN) {
strcat(path, "/");
strcat(path, file);
strcpy(file, path);
static __attribute__((noinline)) int get_cpu_ticks(void)
{
static unsigned long last_utime;
- static int fd;
+ static int fd = -1;
unsigned long utime, ret;
- char buf[128];
+ char buf[256];
+ ssize_t n;
- if (fd == 0)
+ if (fd == -1)
fd = open("/proc/self/stat", O_RDONLY);
+ if (fd == -1)
+ return 0;
lseek(fd, 0, SEEK_SET);
- buf[0] = 0;
- read(fd, buf, sizeof(buf));
- buf[sizeof(buf) - 1] = 0;
+ n = read(fd, buf, sizeof(buf) - 1);
+ if (n <= 0)
+ return 0;
+ buf[n] = 0;
sscanf(buf, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %lu", &utime);
ret = utime - last_utime;
#include <sys/soundcard.h>
#include "out.h"
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+#pragma GCC diagnostic ignored "-Wunused-result"
+#endif
+
////////////////////////////////////////////////////////////////////////
// oss globals
////////////////////////////////////////////////////////////////////////