diff --git a/lib/libICE/ChangeLog b/lib/libICE/ChangeLog index 21a11a22e..ae30bf317 100644 --- a/lib/libICE/ChangeLog +++ b/lib/libICE/ChangeLog @@ -1,3 +1,65 @@ +commit f415da71dd26f128df7d550ecd7631f8888eb1d2 +Author: Alan Coopersmith +Date: Mon Aug 20 13:21:07 2007 -0700 + + Version bump: 1.0.4 + +commit 8e08d3e4b8f00151b3a8b7eb88015dc15170e154 +Author: Alan Coopersmith +Date: Mon Jun 4 15:40:22 2007 -0700 + + Add $(AM_CFLAGS) to lint flags to get correct Xtrans flags + +commit cd900e40b5676874d076c35466fd7baa6a49b1f6 +Author: Alan Coopersmith +Date: Thu Apr 5 15:05:52 2007 -0700 + + Replace many malloc(strlen()); strcpy() pairs with strdup() + +commit 27f9a9324d58c9a7472c724c62f5b7ea0e1f4681 +Author: Alan Coopersmith +Date: Thu Apr 5 14:43:05 2007 -0700 + + Provide ANSI C prototypes for more static functions + +commit bb639803a779ceace05d183b653da88f010ab29c +Author: Alan Coopersmith +Date: Thu Apr 5 14:32:31 2007 -0700 + + Convert authutil.c static helpers to ANSI C prototypes to clear sparse warnings + +commit 2179b2d467d69e45559b8e4f161a904a21f05321 +Author: Alan Coopersmith +Date: Thu Apr 5 14:28:06 2007 -0700 + + Add hooks for checking source code with lint/sparse/etc. + +commit 6b361c028b5ad931b61df86fae570f3ef9f41c15 +Author: Alan Coopersmith +Date: Thu Apr 5 14:19:56 2007 -0700 + + Coverity #1086: Double free of pointer "*listenObjsRet" + + Same bug, different function. + +commit c9b3d016681d81aff32c74cdad75151bd538e6ab +Author: Alan Coopersmith +Date: Thu Apr 5 14:07:42 2007 -0700 + + Coverity #1085: Double free of pointer "*listenObjsRet" + + If malloc failed in the loop in IceListenForConnections, the error path + would free all previous allocations, then loop around and try again, and + if it failed again, free the previous allocations again. On the other + hand, if it succeeded on the later tries, then the memory would just be + leaked, since the error would be returned and not the pointer to them. + +commit 6039e865470af23948b0fe7d5dc0ea72da436b0e +Author: Alan Coopersmith +Date: Thu Apr 5 14:04:01 2007 -0700 + + Add *~ to .gitignore to skip emacs/patch droppings + commit bed718894bed98cbd45b02bd57fb7fc6fd5089aa Author: Daniel Stone Date: Sat Dec 16 01:21:17 2006 +0200 diff --git a/lib/libICE/Makefile.am b/lib/libICE/Makefile.am index d3dd67863..2d72364b8 100644 --- a/lib/libICE/Makefile.am +++ b/lib/libICE/Makefile.am @@ -10,3 +10,8 @@ ChangeLog: (GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2) dist-hook: ChangeLog + +if LINT +lint: + (cd src && $(MAKE) $(MFLAGS) lint) +endif LINT diff --git a/lib/libICE/configure.ac b/lib/libICE/configure.ac index fb79a19db..918e129b5 100644 --- a/lib/libICE/configure.ac +++ b/lib/libICE/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ(2.57) AC_INIT([libICE], - 1.0.3, + 1.0.4, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], libICE) @@ -36,6 +36,11 @@ AC_DEFINE(ICE_t, 1, [Xtrans transport type]) # Checks for header files. AC_HEADER_STDC +dnl Allow checking code with lint, sparse, etc. +XORG_WITH_LINT +XORG_LINT_LIBRARY([ICE]) +LINT_FLAGS="${LINT_FLAGS} ${ICE_CFLAGS} ${XTRANS_CFLAGS}" + if test "x$GCC" = "xyes"; then GCC_WARNINGS="-Wall -Wpointer-arith -Wstrict-prototypes \ -Wmissing-prototypes -Wmissing-declarations \ diff --git a/lib/libICE/depcomp b/lib/libICE/depcomp index 04701da53..ca5ea4e1e 100644 --- a/lib/libICE/depcomp +++ b/lib/libICE/depcomp @@ -1,9 +1,10 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2005-07-09.11 +scriptversion=2006-10-15.18 -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software +# Foundation, Inc. # 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 @@ -91,7 +92,20 @@ gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. - "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" stat=$? if test $stat -eq 0; then : else @@ -276,6 +290,46 @@ icc) rm -f "$tmpdepfile" ;; +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. + sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. @@ -288,13 +342,13 @@ tru64) if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a - # static library. This mecanism is used in libtool 1.4 series to + # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in in $dir.libs/$base.o.d and + # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is diff --git a/lib/libICE/install-sh b/lib/libICE/install-sh index 4d4a9519e..4fbbae7b7 100644 --- a/lib/libICE/install-sh +++ b/lib/libICE/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2005-05-14.22 +scriptversion=2006-10-14.15 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -39,15 +39,24 @@ scriptversion=2005-05-14.22 # when there is no Makefile. # # This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. +# from scratch. + +nl=' +' +IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi -# put in absolute paths if you don't have them in your path; or use env. vars. +# Put in absolute file names if you don't have them in your path; +# or use environment vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" @@ -58,7 +67,13 @@ stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" -chmodcmd="$chmodprog 0755" +posix_glob= +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chmodcmd=$chmodprog chowncmd= chgrpcmd= stripcmd= @@ -95,7 +110,7 @@ Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " -while test -n "$1"; do +while test $# -ne 0; do case $1 in -c) shift continue;; @@ -111,9 +126,15 @@ while test -n "$1"; do --help) echo "$usage"; exit $?;; - -m) chmodcmd="$chmodprog $2" + -m) mode=$2 shift shift + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac continue;; -o) chowncmd="$chownprog $2" @@ -136,25 +157,33 @@ while test -n "$1"; do --version) echo "$0 $scriptversion"; exit $?;; - *) # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - test -n "$dir_arg$dstarg" && break - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dstarg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dstarg" - shift # fnord - fi - shift # arg - dstarg=$arg - done + --) shift break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; esac done -if test -z "$1"; then +if test $# -ne 0 && test -z "$dir_arg$dstarg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done +fi + +if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 @@ -164,6 +193,33 @@ if test -z "$1"; then exit 0 fi +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + for src do # Protect names starting with `-'. @@ -173,15 +229,11 @@ do if test -n "$dir_arg"; then dst=$src - src= - - if test -d "$dst"; then - mkdircmd=: - chmodcmd= - else - mkdircmd=$mkdirprog - fi + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? else + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. @@ -208,53 +260,188 @@ do echo "$0: $dstarg: Is a directory" >&2 exit 1 fi - dst=$dst/`basename "$src"` + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? fi fi - # This sed command emulates the dirname command. - dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` + obsolete_mkdir_used=false - # Make sure that the destination directory exists. + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - # Skip lots of stat calls in the usual case. - if test ! -d "$dstdir"; then - defaultIFS=' - ' - IFS="${IFS-$defaultIFS}" + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac - oIFS=$IFS - # Some sh's can't handle IFS=/ for some reason. - IFS='%' - set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` - shift - IFS=$oIFS + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi - pathcomp= + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - while test $# -ne 0 ; do - pathcomp=$pathcomp$1 + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix=/ ;; + -*) prefix=./ ;; + *) prefix= ;; + esac + + case $posix_glob in + '') + if (set -f) 2>/dev/null; then + posix_glob=true + else + posix_glob=false + fi ;; + esac + + oIFS=$IFS + IFS=/ + $posix_glob && set -f + set fnord $dstdir shift - if test ! -d "$pathcomp"; then - $mkdirprog "$pathcomp" - # mkdir can fail with a `File exist' error in case several - # install-sh are creating the directory concurrently. This - # is OK. - test -d "$pathcomp" || exit + $posix_glob && set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi - pathcomp=$pathcomp/ - done + fi fi if test -n "$dir_arg"; then - $doit $mkdircmd "$dst" \ - && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ - && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ - && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ - && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } - + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else - dstfile=`basename "$dst"` # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ @@ -262,10 +449,9 @@ do # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - trap '(exit $?); exit' 1 2 13 15 # Copy the file name to the temp name. - $doit $cpprog "$src" "$dsttmp" && + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # @@ -276,10 +462,10 @@ do { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ - && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && + && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # Now rename the file to the real destination. - { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ + { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \ || { # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not @@ -291,11 +477,12 @@ do # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { - if test -f "$dstdir/$dstfile"; then - $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ - || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + if test -f "$dst"; then + $doit $rmcmd -f "$dst" 2>/dev/null \ + || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \ + && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\ || { - echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } else @@ -304,16 +491,13 @@ do } && # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + $doit $mvcmd "$dsttmp" "$dst" } - } - fi || { (exit 1); exit 1; } -done + } || exit 1 -# The final little trick to "correctly" pass the exit status to the exit trap. -{ - (exit 0); exit 0 -} + trap '' 0 + fi +done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) diff --git a/lib/libICE/missing b/lib/libICE/missing index 894e786e1..1c8ff7049 100644 --- a/lib/libICE/missing +++ b/lib/libICE/missing @@ -1,9 +1,9 @@ #! /bin/sh # Common stub for a few missing GNU programs while installing. -scriptversion=2005-06-08.21 +scriptversion=2006-05-10.23 -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 # Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. @@ -33,6 +33,8 @@ if test $# -eq 0; then fi run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. @@ -44,7 +46,7 @@ fi msg="missing on your system" -case "$1" in +case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= @@ -77,6 +79,7 @@ Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c @@ -106,7 +109,7 @@ esac # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). -case "$1" in +case $1 in lex|yacc) # Not GNU programs, they don't have --version. ;; @@ -135,7 +138,7 @@ esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. -case "$1" in +case $1 in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if @@ -164,7 +167,7 @@ WARNING: \`$1' is $msg. You should only need it if test -z "$files" && files="config.h" touch_files= for f in $files; do - case "$f" in + case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; @@ -192,8 +195,8 @@ WARNING: \`$1' is needed, but is $msg. You can get \`$1' as part of \`Autoconf' from any GNU archive site." - file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` - test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else @@ -214,25 +217,25 @@ WARNING: \`$1' $msg. You should only need it if in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then + if test $# -ne 1; then eval LASTARG="\${$#}" - case "$LASTARG" in + case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then + if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then + if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi - if [ ! -f y.tab.h ]; then + if test ! -f y.tab.h; then echo >y.tab.h fi - if [ ! -f y.tab.c ]; then + if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; @@ -244,18 +247,18 @@ WARNING: \`$1' is $msg. You should only need it if in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c - if [ $# -ne 1 ]; then + if test $# -ne 1; then eval LASTARG="\${$#}" - case "$LASTARG" in + case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then + if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi - if [ ! -f lex.yy.c ]; then + if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; @@ -267,11 +270,9 @@ WARNING: \`$1' is $msg. You should only need it if \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` - fi - if [ -f "$file" ]; then + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then touch $file else test -z "$file" || exec >$file @@ -289,11 +290,17 @@ WARNING: \`$1' is $msg. You should only need it if DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi @@ -317,13 +324,13 @@ WARNING: \`$1' is $msg. You should only need it if fi firstarg="$1" if shift; then - case "$firstarg" in + case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac - case "$firstarg" in + case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 diff --git a/lib/libICE/src/Makefile.am b/lib/libICE/src/Makefile.am index b549ede14..449aeaf85 100644 --- a/lib/libICE/src/Makefile.am +++ b/lib/libICE/src/Makefile.am @@ -38,3 +38,11 @@ iceinclude_HEADERS=\ $(top_srcdir)/include/X11/ICE/ICEmsg.h \ $(top_srcdir)/include/X11/ICE/ICEproto.h \ $(top_srcdir)/include/X11/ICE/ICEutil.h + +if LINT +ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) + +lint: + $(LINT) $(ALL_LINT_FLAGS) $(libICE_la_SOURCES) $(XINERAMA_LIBS) +endif LINT diff --git a/lib/libICE/src/accept.c b/lib/libICE/src/accept.c index df2b258c5..d54ffd4dd 100644 --- a/lib/libICE/src/accept.c +++ b/lib/libICE/src/accept.c @@ -92,8 +92,7 @@ IceAcceptStatus *statusRet; iceConn->send_sequence = 0; iceConn->receive_sequence = 0; - iceConn->connection_string = (char *) malloc ( - strlen (listenObj->network_id) + 1); + iceConn->connection_string = strdup(listenObj->network_id); if (iceConn->connection_string == NULL) { @@ -102,8 +101,6 @@ IceAcceptStatus *statusRet; *statusRet = IceAcceptBadMalloc; return (NULL); } - else - strcpy (iceConn->connection_string, listenObj->network_id); iceConn->vendor = NULL; iceConn->release = NULL; diff --git a/lib/libICE/src/authutil.c b/lib/libICE/src/authutil.c index 1cc58d8a4..c1d1aeeb0 100644 --- a/lib/libICE/src/authutil.c +++ b/lib/libICE/src/authutil.c @@ -55,12 +55,12 @@ extern unsigned sleep (); #endif #endif -static Status read_short (); -static Status read_string (); -static Status read_counted_string (); -static Status write_short (); -static Status write_string (); -static Status write_counted_string (); +static Status read_short (FILE *file, unsigned short *shortp); +static Status read_string (FILE *file, char **stringp); +static Status read_counted_string (FILE *file, unsigned short *countp, char **stringp); +static Status write_short (FILE *file, unsigned short s); +static Status write_string (FILE *file, char *string); +static Status write_counted_string (FILE *file, unsigned short count, char *string); @@ -71,7 +71,7 @@ static Status write_counted_string (); */ char * -IceAuthFileName () +IceAuthFileName (void) { static char slashDotICEauthority[] = "/.ICEauthority"; @@ -393,11 +393,7 @@ char *auth_name; */ static Status -read_short (file, shortp) - -FILE *file; -unsigned short *shortp; - +read_short (FILE *file, unsigned short *shortp) { unsigned char file_short[2]; @@ -410,10 +406,7 @@ unsigned short *shortp; static Status -read_string (file, stringp) - -FILE *file; -char **stringp; +read_string (FILE *file, char **stringp) { unsigned short len; @@ -445,12 +438,7 @@ char **stringp; static Status -read_counted_string (file, countp, stringp) - -FILE *file; -unsigned short *countp; -char **stringp; - +read_counted_string (FILE *file, unsigned short *countp, char **stringp) { unsigned short len; char *data; @@ -484,11 +472,7 @@ char **stringp; static Status -write_short (file, s) - -FILE *file; -unsigned short s; - +write_short (FILE *file, unsigned short s) { unsigned char file_short[2]; @@ -503,11 +487,7 @@ unsigned short s; static Status -write_string (file, string) - -FILE *file; -char *string; - +write_string (FILE *file, char *string) { unsigned short count = strlen (string); @@ -522,12 +502,7 @@ char *string; static Status -write_counted_string (file, count, string) - -FILE *file; -unsigned short count; -char *string; - +write_counted_string (FILE *file, unsigned short count, char *string) { if (!write_short (file, count)) return (0); diff --git a/lib/libICE/src/connect.c b/lib/libICE/src/connect.c index e06aa04bc..387405881 100644 --- a/lib/libICE/src/connect.c +++ b/lib/libICE/src/connect.c @@ -36,7 +36,8 @@ Author: Ralph Mor, X Consortium #include #include "globals.h" -static XtransConnInfo ConnectToPeer(); +static XtransConnInfo ConnectToPeer(char *networkIdsList, + char **actualConnectionRet); #define Strstr strstr @@ -449,11 +450,7 @@ IceConn iceConn; static XtransConnInfo -ConnectToPeer (networkIdsList, actualConnectionRet) - -char *networkIdsList; -char **actualConnectionRet; - +ConnectToPeer (char *networkIdsList, char **actualConnectionRet) { char addrbuf[256]; char* address; @@ -527,9 +524,7 @@ char **actualConnectionRet; * We need to return the actual network connection string */ - *actualConnectionRet = (char *) malloc (strlen (address) + 1); - strcpy (*actualConnectionRet, address); - + *actualConnectionRet = strdup(address); /* * Return the file descriptor diff --git a/lib/libICE/src/getauth.c b/lib/libICE/src/getauth.c index 73fcd8aec..4ad787875 100644 --- a/lib/libICE/src/getauth.c +++ b/lib/libICE/src/getauth.c @@ -35,7 +35,8 @@ Author: Ralph Mor, X Consortium #include "ICElibint.h" #include -static Bool auth_valid (); +static Bool auth_valid (const char *auth_name, int num_auth_names, + char **auth_names, int *index_ret); extern int _IcePaAuthDataEntryCount; extern IceAuthDataEntry _IcePaAuthDataEntries[]; @@ -244,12 +245,8 @@ int *indices_ret; /* in/out arg */ */ static Bool -auth_valid (auth_name, num_auth_names, auth_names, index_ret) - -char *auth_name; -int num_auth_names; -char **auth_names; -int *index_ret; +auth_valid (const char *auth_name, int num_auth_names, + char **auth_names, int *index_ret) { /* diff --git a/lib/libICE/src/iceauth.c b/lib/libICE/src/iceauth.c index 01c73ced3..dcee7ed5d 100644 --- a/lib/libICE/src/iceauth.c +++ b/lib/libICE/src/iceauth.c @@ -38,7 +38,7 @@ Author: Ralph Mor, X Consortium #include #define Time_t time_t -static int binaryEqual (); +static int binaryEqual (const char *a, const char *b, unsigned len); static int was_called_state; @@ -135,12 +135,10 @@ char **errorStringRet; if (!data) { - char *tempstr = + const char *tempstr = "Could not find correct MIT-MAGIC-COOKIE-1 authentication"; - *errorStringRet = (char *) malloc (strlen (tempstr) + 1); - if (*errorStringRet) - strcpy (*errorStringRet, tempstr); + *errorStringRet = strdup(tempstr); return (IcePoAuthFailed); } @@ -161,11 +159,10 @@ char **errorStringRet; * a single pass authentication method. */ - char *tempstr = "MIT-MAGIC-COOKIE-1 authentication internal error"; + const char *tempstr = + "MIT-MAGIC-COOKIE-1 authentication internal error"; - *errorStringRet = (char *) malloc (strlen (tempstr) + 1); - if (*errorStringRet) - strcpy (*errorStringRet, tempstr); + *errorStringRet = strdup(tempstr); return (IcePoAuthFailed); } @@ -226,11 +223,10 @@ char **errorStringRet; } else { - char *tempstr = "MIT-MAGIC-COOKIE-1 authentication rejected"; + const char *tempstr + = "MIT-MAGIC-COOKIE-1 authentication rejected"; - *errorStringRet = (char *) malloc (strlen (tempstr) + 1); - if (*errorStringRet) - strcpy (*errorStringRet, tempstr); + *errorStringRet = strdup(tempstr); stat = IcePaAuthRejected; } @@ -246,12 +242,10 @@ char **errorStringRet; * always find a valid entry. */ - char *tempstr = + const char *tempstr = "MIT-MAGIC-COOKIE-1 authentication internal error"; - *errorStringRet = (char *) malloc (strlen (tempstr) + 1); - if (*errorStringRet) - strcpy (*errorStringRet, tempstr); + *errorStringRet = strdup(tempstr); return (IcePaAuthFailed); } @@ -265,10 +259,7 @@ char **errorStringRet; */ static int -binaryEqual (a, b, len) - -register char *a, *b; -register unsigned len; +binaryEqual (const char *a, const char *b, unsigned len) { while (len--) diff --git a/lib/libICE/src/listen.c b/lib/libICE/src/listen.c index 7708cfe02..d3aa4b25f 100644 --- a/lib/libICE/src/listen.c +++ b/lib/libICE/src/listen.c @@ -123,8 +123,10 @@ char *errorStringRet; free ((char *) (*listenObjsRet)[j]); free ((char *) *listenObjsRet); + *listenObjsRet = NULL; status = 0; + break; } else { @@ -175,14 +177,7 @@ IceGetListenConnectionString (listenObj) IceListenObj listenObj; { - char *networkId; - - networkId = (char *) malloc (strlen (listenObj->network_id) + 1); - - if (networkId) - strcpy (networkId, listenObj->network_id); - - return (networkId); + return strdup(listenObj->network_id); } diff --git a/lib/libICE/src/listenwk.c b/lib/libICE/src/listenwk.c index f97aa44af..26bb6e026 100644 --- a/lib/libICE/src/listenwk.c +++ b/lib/libICE/src/listenwk.c @@ -127,8 +127,10 @@ char *errorStringRet; free ((char *) (*listenObjsRet)[j]); free ((char *) *listenObjsRet); + *listenObjsRet = NULL; status = 0; + break; } else { diff --git a/lib/libICE/src/misc.c b/lib/libICE/src/misc.c index 45c1f7ea0..304ae60f9 100644 --- a/lib/libICE/src/misc.c +++ b/lib/libICE/src/misc.c @@ -129,12 +129,7 @@ IceVendor (iceConn) IceConn iceConn; { - char *string = (char *) malloc (strlen (iceConn->vendor) + 1); - - if (string) - strcpy (string, iceConn->vendor); - - return (string); + return strdup(iceConn->vendor); } @@ -144,12 +139,7 @@ IceRelease (iceConn) IceConn iceConn; { - char *string = (char *) malloc (strlen (iceConn->release) + 1); - - if (string) - strcpy (string, iceConn->release); - - return (string); + return strdup(iceConn->release); } @@ -191,13 +181,7 @@ IceConn iceConn; { if (iceConn->connection_string) { - char *string = (char *) malloc ( - strlen (iceConn->connection_string) + 1); - - if (string) - strcpy (string, iceConn->connection_string); - - return (string); + return strdup(iceConn->connection_string); } else return (NULL); diff --git a/lib/libICE/src/process.c b/lib/libICE/src/process.c index 2a97dcbe8..416f1c600 100644 --- a/lib/libICE/src/process.c +++ b/lib/libICE/src/process.c @@ -615,7 +615,7 @@ IceReplyWaitInfo *replyWait; _IceConnectionError *errorReply = &(((_IceReply *) (replyWait->reply))->connection_error); char *errorStr = NULL; - char *tempstr; + const char *tempstr; char *prefix, *temp; invokeHandler = 0; @@ -627,16 +627,14 @@ IceReplyWaitInfo *replyWait; tempstr = "None of the ICE versions specified are supported"; - errorStr = (char *) malloc (strlen (tempstr) + 1); - strcpy (errorStr, tempstr); + errorStr = strdup(tempstr); break; case IceNoAuth: tempstr = "None of the authentication protocols specified are supported"; - errorStr = (char *) malloc (strlen (tempstr) + 1); - strcpy (errorStr, tempstr); + errorStr = strdup(tempstr); break; case IceSetupFailed: @@ -697,16 +695,14 @@ IceReplyWaitInfo *replyWait; temp = "None of the protocol versions specified are supported"; - errorStr = (char *) malloc (strlen (temp) + 1); - strcpy (errorStr, temp); + errorStr = strdup(temp); break; case IceNoAuth: temp = "None of the authentication protocols specified are supported"; - errorStr = (char *) malloc (strlen (temp) + 1); - strcpy (errorStr, temp); + errorStr = strdup(temp); break; case IceSetupFailed: @@ -1129,11 +1125,11 @@ IceReplyWaitInfo *replyWait; _IceConnectionError *errorReply = &(((_IceReply *) (replyWait->reply))->connection_error); - char *tempstr = "Received bad authIndex in the AuthRequired message"; + const char *tempstr + = "Received bad authIndex in the AuthRequired message"; char errIndex = (int) message->authIndex; - errorString = (char *) malloc (strlen (tempstr) + 1); - strcpy (errorString, tempstr); + errorString = strdup(tempstr); errorReply->type = ICE_CONNECTION_ERROR; errorReply->error_message = errorString; @@ -1159,11 +1155,11 @@ IceReplyWaitInfo *replyWait; _IceProtocolError *errorReply = &(((_IceReply *) (replyWait->reply))->protocol_error); - char *tempstr = "Received bad authIndex in the AuthRequired message"; + const char *tempstr + = "Received bad authIndex in the AuthRequired message"; char errIndex = (int) message->authIndex; - errorString = (char *) malloc (strlen (tempstr) + 1); - strcpy (errorString, tempstr); + errorString = strdup(tempstr); errorReply->type = ICE_PROTOCOL_ERROR; errorReply->error_message = errorString; diff --git a/lib/libICE/src/register.c b/lib/libICE/src/register.c index 20e60dfdf..bcf95a2cb 100644 --- a/lib/libICE/src/register.c +++ b/lib/libICE/src/register.c @@ -85,8 +85,7 @@ IceIOErrorProc IOErrorProc; char *name; _IceProtocols[_IceLastMajorOpcode].protocol_name = name = - (char *) malloc (strlen (protocolName) + 1); - strcpy (name, protocolName); + strdup(protocolName); p = _IceProtocols[_IceLastMajorOpcode].orig_client = (_IcePoProtocol *) malloc (sizeof (_IcePoProtocol)); @@ -96,11 +95,8 @@ IceIOErrorProc IOErrorProc; opcodeRet = ++_IceLastMajorOpcode; } - p->vendor = (char *) malloc (strlen (vendor) + 1); - strcpy (p->vendor, vendor); - - p->release = (char *) malloc (strlen (release) + 1); - strcpy (p->release, release); + p->vendor = strdup(vendor); + p->release = strdup(release); p->version_count = versionCount; @@ -119,10 +115,7 @@ IceIOErrorProc IOErrorProc; for (i = 0; i < authCount; i++) { - p->auth_names[i] = - (char *) malloc (strlen (authNames[i]) + 1); - strcpy (p->auth_names[i], authNames[i]); - + p->auth_names[i] = strdup(authNames[i]); p->auth_procs[i] = authProcs[i]; } } @@ -197,8 +190,7 @@ IceIOErrorProc IOErrorProc; char *name; _IceProtocols[_IceLastMajorOpcode].protocol_name = name = - (char *) malloc (strlen (protocolName) + 1); - strcpy (name, protocolName); + strdup(protocolName); _IceProtocols[_IceLastMajorOpcode].orig_client = NULL; @@ -208,11 +200,8 @@ IceIOErrorProc IOErrorProc; opcodeRet = ++_IceLastMajorOpcode; } - p->vendor = (char *) malloc (strlen (vendor) + 1); - strcpy (p->vendor, vendor); - - p->release = (char *) malloc (strlen (release) + 1); - strcpy (p->release, release); + p->vendor = strdup(vendor); + p->release = strdup(release); p->version_count = versionCount; @@ -234,10 +223,7 @@ IceIOErrorProc IOErrorProc; for (i = 0; i < authCount; i++) { - p->auth_names[i] = - (char *) malloc (strlen (authNames[i]) + 1); - strcpy (p->auth_names[i], authNames[i]); - + p->auth_names[i] = strdup(authNames[i]); p->auth_procs[i] = authProcs[i]; } } diff --git a/lib/libICE/src/setauth.c b/lib/libICE/src/setauth.c index 4fd77182a..8ed9cef42 100644 --- a/lib/libICE/src/setauth.c +++ b/lib/libICE/src/setauth.c @@ -96,20 +96,14 @@ IceAuthDataEntry *entries; _IcePaAuthDataEntryCount++; } - _IcePaAuthDataEntries[j].protocol_name = (char *) malloc ( - strlen (entries[i].protocol_name) + 1); - strcpy (_IcePaAuthDataEntries[j].protocol_name, - entries[i].protocol_name); + _IcePaAuthDataEntries[j].protocol_name + = strdup(entries[i].protocol_name); - _IcePaAuthDataEntries[j].network_id = (char *) malloc ( - strlen (entries[i].network_id) + 1); - strcpy (_IcePaAuthDataEntries[j].network_id, - entries[i].network_id); + _IcePaAuthDataEntries[j].network_id + = strdup(entries[i].network_id); - _IcePaAuthDataEntries[j].auth_name = (char *) malloc ( - strlen (entries[i].auth_name) + 1); - strcpy (_IcePaAuthDataEntries[j].auth_name, - entries[i].auth_name); + _IcePaAuthDataEntries[j].auth_name + = strdup(entries[i].auth_name); _IcePaAuthDataEntries[j].auth_data_length = entries[i].auth_data_length;