Commit Graph

18 Commits

Author SHA1 Message Date
Pedro Alves 59cc050d89 gdb.base/fileio.c: Fix several -Wmaybe-uninitialized warnings
src/gdb/testsuite/gdb.base/fileio.c: In function ‘test_write’:
 src/gdb/testsuite/gdb.base/fileio.c:158:5: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      printf ("write 1: ret = %d, errno = %d\n", ret, errno);
      ^

gdb/ChangeLog:
2017-05-18  Pedro Alves  <palves@redhat.com>

	* gdb.base/fileio.c (test_write, test_read, test_close)
	(test_fstat): Don't print 'ret' in the fail path.
2017-05-18 12:56:38 +01:00
Pedro Alves c8f6abd10d gdb.base/fileio.c: Fix several -Wreturn-type warnings
All the "test_" functions warn like:

  src/gdb/testsuite/gdb.base/fileio.c: In function ‘test_close’:
  src/gdb/testsuite/gdb.base/fileio.c:280:1: warning: control reaches end of non-void function [-Wreturn-type]
   }
   ^

Nothing looks at the return of these functions, so just make them
return void.  While at it, "()" is not the same as "(void)" in C - fix
that too.

gdb/ChangeLog:
2017-05-18  Pedro Alves  <palves@redhat.com>

	* gdb.base/fileio.c (stop, test_open, test_write, test_read)
	(test_lseek, test_close, test_stat, test_fstat, test_isatty)
	(test_system, test_rename, test_unlink, test_time): Change
	prototypes.
	* gdb.base/fileio.exp (stop_msg): Adjust.
2017-05-18 12:56:16 +01:00
Pedro Alves d2a03b7745 gdb.base/fileio.exp: Remove nowarnings
... and quiet -Wnonnull in a different way.

gdb/testsuite/ChangeLog:
2017-05-18  Pedro Alves  <palves@redhat.com>

	* gdb.base/fileio.c (null_str): New global.
	(test_stat): Use it.
	* gdb.base/fileio.exp: Remove nowarnings.
2017-05-18 11:47:05 +01:00
Andreas Arnez a59add0c2e GDB testsuite: Fix warnings with -std=gnu11
Since upstream GCC has changed the default C language dialect to
'gnu11', it yields multiple warnings in the GDB testsuite for missing
function return types and implicit function declarations.  This patch
attempts to fix these.

gdb/testsuite/ChangeLog:

	* gdb.ada/cond_lang/foo.c (callme): Add return type.
	* gdb.base/call-sc.c (zed): Likewise.
	* gdb.base/checkpoint.c (main): Likewise.
	* gdb.base/dump.c (main): Likewise.
	* gdb.base/gcore.c (main): Likewise.
	* gdb.base/huge.c (main): Likewise.
	* gdb.base/multi-forks.c (main): Likewise.
	* gdb.base/pr10179-a.c (main): Likewise.
	* gdb.base/savedregs.c (main): Likewise.
	* gdb.base/sigaltstack.c (main): Likewise.
	* gdb.base/siginfo.c (main): Likewise.
	* gdb.base/structs.c (zed): Likewise.
	* gdb.mi/mi-stack.c (callee3, callee2, callee1, main): Likewise.
	* gdb.mi/mi-syn-frame.c (main): Likewise.
	* gdb.mi/until.c (foo, main): Likewise.
	* gdb.base/global-var-nested-by-dso.c (b_main, c_main): Declare.
	* gdb.base/solib-weak.c (foo): Declare.
	* gdb.base/attach-twice.c: Include stdio.h.
	* gdb.base/weaklib1.c: Likewise.
	* gdb.base/weaklib2.c: Likewise.
	* gdb.base/catch-signal-fork.c: Include stdio.h and sys/wait.h.
	* gdb.mi/mi-condbreak-call-thr-state-mt.c: Include stdio.h and
	unistd.h.
	* gdb.base/attach-pie-misread.c: Include stdlib.h.
	* gdb.mi/mi-exit-code.c: Likewise.
	* gdb.base/break-interp-lib.c: Include string.h.
	* gdb.base/coremaker.c: Likewise.
	* gdb.base/testenv.c: Likewise.
	* gdb.python/py-finish-breakpoint.c: Likewise.
	* gdb.base/inferior-died.c: Include sys/wait.h.
	* gdb.base/fileio.c: Include time.h.
	* gdb.base/async-shell.c: Include unistd.h.
	* gdb.base/dprintf-non-stop.c: Likewise.
	* gdb.base/info-os.c: Likewise.
	* gdb.mi/mi-console.c: Likewise.
	* gdb.mi/watch-nonstop.c: Likewise.
	* gdb.python/py-events.c: Likewise.
	* gdb.base/async.c (baz): Move up before its invocation.
	* gdb.base/code_elim2.c (my_global_func): Likewise.
	* gdb.base/skip-solib-lib.c (multiply): Likewise.
	* gdb.base/advance.c (func2): Likewise.
2014-11-13 10:20:44 +01:00
Yao Qi 0ea4d52e43 Close the file in fileio.exp test
I see the following fail in fileio.exp on mingw32 host gdb,

rename 1: ret = -1, errno = 13^M
^M
Breakpoint 2, stop () at fileio.c:76^M
76      static void stop () {}^M
(gdb) FAIL: gdb.base/fileio.exp: Rename a file

the test fails to rename a file which is not expected.  The previous
test test_write doesn't close the file, so the rename fails as a
result on Windows.  This patch fixes it by closing file in test_write,
and the fail goes away.

rename 1: ret = 0, errno = 0 OK^M
^M
Breakpoint 2, stop () at fileio.c:76^M
76      static void stop () {}^M
(gdb) PASS: gdb.base/fileio.exp: Rename a file

gdb/testsuite:

2014-10-29  Yao Qi  <yao@codesourcery.com>

	* gdb.base/fileio.c (test_write): Close the file.
2014-10-29 21:43:05 +08:00
Hui Zhu 9f5a4cef68 Add system test before "set remote system-call-allowed 1" to fileio.exp
This patch is update version according to the discussion in
https://www.sourceware.org/ml/gdb-patches/2009-11/msg00090.html.
If test get the target doesn't support fileio system according to the
remote log.   It will set this test as "unsupported".

Before I made this patch, I want add a check before all of tests in this
file.  But I found that the target maybe support one call but not others.
For example: my target support Fwrite, Fopen and so on.  But not Fgettimeofday.
And it doesn't support Fsystem NULL but it support Fsystem not NULL.
So I think if we want to check target support fileio, we need check them
one by one.

2014-06-04  Nathan Sidwell  <nathan@codesourcery.com>
	    Hui Zhu  <hui@codesourcery.com>

	* gdb.base/fileio.exp: Add test for shell not available as well as
	available.
	* gdb.base/fileio.c (test_system): Check for shell twice.
2014-06-04 14:38:16 +08:00
Tom Tromey b44b82afd9 update fileio test
This updates the fileio test to be parallel-safe.

2013-11-04  Tom Tromey  <tromey@redhat.com>

	* gdb.base/fileio.c (test_open, test_write, test_read)
	(test_lseek, test_close, test_stat, test_fstat)
	(test_isatty, test_system, test_rename, test_unlink):
	Use OUTDIR define.
	* gdb.base/fileio.exp: Define OUTDIR during compilation.
	Use standard_output_file.
2013-11-04 11:02:08 -07:00
Pierre Muller 209f53f524 * gdb.base/fileio.c (test_lseek): typecast ofs_t ret variable to
long type.
	(test_unlink): Correct printf string.
	* gdb.base/checkpoint.c (main): Correct fprintf string for variable i.
	* gdb.threads/attachstop-mt.c: Add #include <string.h>.
2009-10-01 15:39:13 +00:00
Nathan Sidwell 5600ea19e0 gdb/
* remote-file.io.c (remote_fileio_func_system): Treat zero length
	string as NULL.  Adjust for NULL pointer argument.
	* doc/gdb.texinfo (system): Document behaviour with zero length
	string.

	gdb/testsuite/
	* gdb.base/fileio.c: Add system(NULL) test.
	* gdb.base/fileio.exp: Check it.
2006-06-13 08:55:22 +00:00
Nathan Sidwell e1c2defab5 * gdb.base/break.c: Add 10a breakpoint at }
* gdb.base/break.exp: Add test for breakpoint at }
	* gdb.cp/anon-union.cc: Add code at end of function.
	* gdb.cp/anon-union.exp: Adjust end of function breakpoint.
	* gdb.mi/var-cmd.c: Add code at end of function.
	* gdb.mi/mi-var-display.exp: Adjust end of next.
	* gdb.mi/mi2-var-display.exp: Likewise.
	* gdb.base/fileio.c: Add stop function and insert calls at
	stopping places.
	* gdb.base/fileio.exp: Breakpoint stop function and remove
	explicit line number references.
2006-06-13 08:46:17 +00:00
Corinna Vinschen 4d074752ec * gdb.base/fileio.c: Include unistd.h as required for lseek(2). 2005-01-10 15:58:23 +00:00
Mark Kettenis 005bc093f6 * gdb.base/fileio.c (test_open): Replace O_RDONLY with O_RDWR such
that opening the file succeeds on OpenBSD.
2004-02-01 18:51:29 +00:00
Andrew Cagney 60ad077b5a 2004-01-07 Andrew Cagney <cagney@redhat.com>
* gdb.base/fileio.c (strerrno): Add "EBUSY".
2004-01-07 16:39:02 +00:00
Andrew Cagney 1c9b8f3352 2004-01-07 Andrew Cagney <cagney@redhat.com>
* gdb.base/fileio.c (test_open): Do not pass S_IWUSR to "open"
	when creating the read-only file.  From analysis by Roland McGrath
	and Elena Zannoni.
2004-01-07 16:02:27 +00:00
Andrew Cagney ede47fe902 Revert accidental commit. 2004-01-02 22:53:12 +00:00
Andrew Cagney e42c953419 2004-01-02 Andrew Cagney <cagney@redhat.com>
* utils.c (do_my_cleanups): Make static, add forward declaration.
	* defs.h (do_my_cleanups): Delete declaration.
2004-01-02 17:35:01 +00:00
Andrew Cagney b257a0d30a 2003-06-14 Andrew Cagney <cagney@redhat.com>
* gdb.base/fileio.c: Include <errno.h>, and <sys/wait.h>.  Gag
	-Wformat errors.  Add lost line.  Use WEXITSTATUS to get system
	exit status.
	* gdb.base/fileio.exp: Disable target when nointerrupts and
	noinferiorio, instead of limiting it to remote.  Use remote_exec
	instead of system.
2003-06-14 16:51:42 +00:00
Corinna Vinschen 6aeb981f43 * gdb.base/fileio.c: New file, testing File-I/O.
* gdb.base/fileio.exp: Ditto.
2003-06-10 14:38:04 +00:00