Browse Source

fl_wrapper: fix gcc 4.7 warnings by handling return values properly

stable/0.6
Alejandro Mery 12 years ago
committed by Alejandro Mery
parent
commit
3ae3b959c8
3 changed files with 39 additions and 21 deletions
  1. +14
    -7
      src/tools-source/fl_stparse.c
  2. +3
    -3
      src/tools-source/fl_wrapper/Makefile
  3. +22
    -11
      src/tools-source/fl_wrparse.c

+ 14
- 7
src/tools-source/fl_stparse.c

@ -1,22 +1,24 @@
/*
* --- T2-COPYRIGHT-NOTE-BEGIN ---
* --- SDE-COPYRIGHT-NOTE-BEGIN ---
* This copyright note is auto-generated by ./scripts/Create-CopyPatch.
*
* T2 SDE: misc/tools-source/fl_stparse.c
*
* Filename: src/tools-source/fl_stparse.c
* Copyright (C) 2013 The OpenSDE Project
* Copyright (C) 2004 - 2006 The T2 SDE Project
* Copyright (C) 1998 - 2003 Clifford Wolf
*
*
* More information can be found in the files COPYING and README.
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License. A copy of the
* GNU General Public License can be found in the file COPYING.
* --- T2-COPYRIGHT-NOTE-END ---
* --- SDE-COPYRIGHT-NOTE-END ---
*/
#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@ -142,7 +144,12 @@ int main(int argc, char ** argv) {
}
if ( sscanf(line, "%d chdir(\"%[^\"]", &pid, buf1) == 2 ) {
chdir( getproc(pid)->cwd ); chdir( buf1 );
if (chdir(getproc(pid)->cwd) < 0 ||
chdir(buf1) < 0) {
fprintf(stderr, "fl_stparse: Can't get proc %d's cwd! %s\n",
pid, strerror(errno));
exit(1);
}
setproc(pid, getcwd((char *) NULL, 0) );
continue;
}

+ 3
- 3
src/tools-source/fl_wrapper/Makefile

@ -2,7 +2,7 @@
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: src/tools-source/fl_wrapper/Makefile
# Copyright (C) 2009 - 2010 The OpenSDE Project
# Copyright (C) 2009 - 2013 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
@ -41,11 +41,11 @@ SRCS=fl_wrapper.c fl_wrapper_execl.c $(GENERATED)
.PHONY: clean test gdb
$(LIB): $(SRCS) $(HEADER)
$(CC) $(CFLAGS) $(LIB_LDFLAGS) -o "$@.tmp" $<
$(CC) $(CFLAGS) -o "$@.tmp" $< $(LIB_LDFLAGS)
mv "$@.tmp" "$@"
$(FLTEST): fl_wrapper_test.c
$(CC) $(CFLAGS) $(BIN_LDFLAGS) -o $@ $<
$(CC) $(CFLAGS) -o $@ $< $(BIN_LDFLAGS)
test: $(LIB) $(FLTEST)
sh ./fl_wrapper_test.sh

+ 22
- 11
src/tools-source/fl_wrparse.c

@ -1,22 +1,24 @@
/*
* --- T2-COPYRIGHT-NOTE-BEGIN ---
* --- SDE-COPYRIGHT-NOTE-BEGIN ---
* This copyright note is auto-generated by ./scripts/Create-CopyPatch.
*
* T2 SDE: misc/tools-source/fl_wrparse.c
*
* Filename: src/tools-source/fl_wrparse.c
* Copyright (C) 2013 The OpenSDE Project
* Copyright (C) 2004 - 2006 The T2 SDE Project
* Copyright (C) 1998 - 2003 Clifford Wolf
*
*
* More information can be found in the files COPYING and README.
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License. A copy of the
* GNU General Public License can be found in the file COPYING.
* --- T2-COPYRIGHT-NOTE-END ---
* --- SDE-COPYRIGHT-NOTE-END ---
*/
#define _GNU_SOURCE
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/stat.h>
@ -25,7 +27,7 @@
char * get_realname(char * origname) {
static char buf[FILENAME_MAX];
char *file, odir[FILENAME_MAX];
char *file, odir[FILENAME_MAX] = "";
if (! strcmp(origname, "/")) return "/";
@ -37,9 +39,15 @@ char * get_realname(char * origname) {
*file=0; file++;
file = origname + (file-buf);
}
getcwd(odir, FILENAME_MAX); chdir(buf);
getcwd(buf, FILENAME_MAX); chdir(odir);
if (getcwd(odir, FILENAME_MAX) == NULL ||
chdir(buf) < 0 ||
getcwd(buf, FILENAME_MAX) == NULL ||
chdir(odir) < 0) {
fprintf(stderr,"fl_wrapper:getcwd/chdir: (%s:%s): %s\n", odir, buf,
strerror(errno));
return NULL;
}
if (strcmp(buf, "/")) strcat(buf,"/");
strcat(buf, file);
@ -97,7 +105,10 @@ int main(int argc, char ** argv) {
}
}
if ( rootdir != NULL ) chdir(rootdir);
if (rootdir && chdir(rootdir) < 0) {
fprintf(stderr, "fl_wrapper: rootdir=%s: %s\n", rootdir, strerror(errno));
return 1;
}
while ( fgets(buf, FILENAME_MAX, stdin) != NULL ) {

Loading…
Cancel
Save