Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.9k stars 540 forks source link

RC3 pp_sys.c #ifdef usage wrong #5730

Closed p5pRT closed 21 years ago

p5pRT commented 22 years ago

Migrated from rt.perl.org#10074 (status was 'resolved')

Searchable as RT10074$

p5pRT commented 22 years ago

From W.BRISCOE@ponl.com

Created by w.briscoe@ponl.com

On win32 - W2K and W98SE - the following compiler diagnostic is given. On AIX\, no such diagnostic is given.

cl -c -I..\lib\CORE -I.\include -I. -I.. [...] ..\pp_sys.c pp_sys.c ...\pp_sys.c(2209) : warning C4715​: 'Perl_pp_ioctl' : not all control paths return a value

The problem is in the code​:

C​:\perl-5.8.0-RC3> sed 2174\,2209!d pp_sys.c   if (optype == OP_IOCTL) #ifdef HAS_IOCTL   retval = PerlLIO_ioctl(PerlIO_fileno(IoIFP(io))\, func\, s); #else   DIE(aTHX_ "ioctl is not implemented"); #endif   else #ifdef HAS_FCNTL #if defined(OS2) && defined(__EMX__)   retval = fcntl(PerlIO_fileno(IoIFP(io))\, func\, (int)s); #else   retval = fcntl(PerlIO_fileno(IoIFP(io))\, func\, s); #endif

  if (SvPOK(argsv)) {   if (s[SvCUR(argsv)] != 17)   DIE(aTHX_ "Possible memory corruption​: %s overflowed 3rd argument"\,   OP_NAME(PL_op));   s[SvCUR(argsv)] = 0; /* put our null back */   SvSETMAGIC(argsv); /* Assume it has changed */   }

  if (retval == -1)   RETPUSHUNDEF;   if (retval != 0) {   PUSHi(retval);   }   else {   PUSHp(zero_but_true\, ZBTLEN);   }   RETURN;

#else   DIE(aTHX_ "fcntl is not implemented"); #endif }

C​:\perl-5.8.0-RC3>

With HAS_IOCTL and !HAS_FCNTL\, this reduces to​:

  if (optype == OP_IOCTL)   retval = PerlLIO_ioctl(PerlIO_fileno(IoIFP(io))\, func\, s);   else   DIE(aTHX_ "fcntl is not implemented"); }

This is macro-expanded to​:

  if (optype == OP_IOCTL)   retval = win32_ioctl((Perl_PerlIO_fileno(my_perl\, ((XPVIO*) (io)->sv_any)->xio_ifp))\, (func)\, (s));   else   return Perl_die(my_perl\, "fcntl is not implemented"); }

This incorrect code MAY do what is needed if retval is written via the register which returns the value of Perl_pp_ioctl().

This is a minimum change to produce plausible code​:

C​:\perl-5.8.0-RC3\win32> \wfb\bin\diff -c ../0pp_sys.c ../pp_sys.c *** ../0pp_sys.c Sat Jul 13 14​:56​:14 2002 --- ../pp_sys.c Mon Jul 15 20​:52​:10 2002 *************** *** 2201\,2211 ****   else {   PUSHp(zero_but_true\, ZBTLEN);   } - RETURN; -   #else   DIE(aTHX_ "fcntl is not implemented");   #endif   }

  PP(pp_flock) --- 2201\,2210 ----   else {   PUSHp(zero_but_true\, ZBTLEN);   }   #else   DIE(aTHX_ "fcntl is not implemented");   #endif + RETURN;   }

  PP(pp_flock)

C​:\perl-5.8.0-RC3\win32> dmake ..\pp_sys.obj cl -c -I..\lib\CORE -I.\include -I. -I.. [...] ..\pp_sys.c pp_sys.c

C​:\perl-5.8.0-RC3\win32>

I think this change produces a more pleasing structure​:

C​:\perl-5.8.0-RC3\win32> \wfb\bin\diff -c ../0pp_sys.c ../pp_sys.c *** ../0pp_sys.c Sat Jul 13 14​:56​:14 2002 --- ../pp_sys.c Mon Jul 15 21​:04​:04 2002 *************** *** 2178\,2184 ****   DIE(aTHX_ "ioctl is not implemented");   #endif   else ! #ifdef HAS_FCNTL   #if defined(OS2) && defined(__EMX__)   retval = fcntl(PerlIO_fileno(IoIFP(io))\, func\, (int)s);   #else --- 2178\,2186 ----   DIE(aTHX_ "ioctl is not implemented");   #endif   else ! #ifndef HAS_FCNTL ! DIE(aTHX_ "fcntl is not implemented"); ! #else   #if defined(OS2) && defined(__EMX__)   retval = fcntl(PerlIO_fileno(IoIFP(io))\, func\, (int)s);   #else *************** *** 2201\,2211 ****   else {   PUSHp(zero_but_true\, ZBTLEN);   } - RETURN; - - #else - DIE(aTHX_ "fcntl is not implemented");   #endif   }

  PP(pp_flock) --- 2203\,2210 ----   else {   PUSHp(zero_but_true\, ZBTLEN);   }   #endif + RETURN;   }

  PP(pp_flock)

C​:\perl-5.8.0-RC2>

Perl Info ``` Flags: category=install severity=medium Site configuration information for perl v5.8.0: Configured by Administrator at Mon Jul 15 20:24:01 2002. Summary of my perl5 (revision 5 version 8 subversion 0) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cl', ccflags ='-MD -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX', optimize='-MD -DNDEBUG -O1', cppflags='-DWIN32' ccversion='', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -release -libpath:"c:\perl\5.8.0\lib\MSWin32-x86-multi-thread\CORE" -machine:x8 6' libpth=\lib libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib gnulibc_version='undef' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release -libpath:"c:\perl\5.8.0\lib\MSWin32-x86-multi-thread\CORE" -machine:x8 6' Locally applied patches: @INC for perl v5.8.0: C:/perl-5.8.0-RC3/lib . Environment for perl v5.8.0: HOME=C:\WFB LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=C:\PF\MVS\COMMON\msdev98\BIN;C:\PF\MVS\VC98\BIN;C:\PF\MVS\COMMON\TOOL S\WIN NT;C:\PF\MVS\COMMON\TOOLS;c:\perl\5.6.1\bin;c:\perl\5.6.1\bin\MSWin32-x86; C:\wf b\SFU\common\;C:\SFU\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\WINNT\System3 2\Wbe m;c:\wfb\bin;C:\PF\IShield\I55PE\Program;C:\PF\W2KRK\;C:\PF\MsoftSDK\Bin\. ;C:\P F\MsoftSDK\Bin\WinNT\.;\bin\ide;\bin;c:\pf\dvstudio\vc\bin;C:\PF\MsoftSDK\ Bin\. ;C:\PF\MsoftSDK\Bin\WinNT\.;C:\orawin95\bin;C:\WINME;C:\WINME\COMMAND;C:\W FB\BI N;C:\PF\ISHIELD\I55PE\PROGRAM;C:\wfb\ftp\ftp.cs.pdx.edu\pub\elvis\extract; C:\cy gwin\bin PERL_BADLANG (unset) SHELL (unset) ------------------------------------------------------------------- The contents of this e-mail are confidential to the ordinary user of the e-mail address to which it was addressed and may also be privileged. If you are not the addressee of this e-mail you should not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please notify us by telephone or e-mail the sender by replying to this message, and then delete this e-mail and other copies of it from your computer system. Thank you. We reserve the right to monitor all e-mail communications through our network. ```
p5pRT commented 21 years ago

From @jhi

This patch made it in to Perl 5.8.0\, I'm marking the problem ticket as resolved.

p5pRT commented 21 years ago

@jhi - Status changed from 'open' to 'resolved'