Skip to content

Commit

Permalink
edk2-libc: Support for compiling Python UEFI interpreter with VS2022
Browse files Browse the repository at this point in the history
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4811

While trying to compile Python UEFI 3.6.8 with VS2022, got several
compiler warnings from other components within the edk2-libc project.
These warnings were leading to compilation failure as they were
treated as errors. All these issues have been fixed through this
commit. Besides this, updated the year in copy right of these file.

Summary of the issues is given below for reference:
1.AppPkg\Applications\Enquire\Enquire.c
  Warning C4459: Declaration of 'bugs' hides global declaration.
  Warning C4456: Multiple declarations of 'char_max' hide previous
                 local declarations.
  Warning C4456: Declaration of 'char_min' hides previous local
                 declaration.

2.AppPkg\Applications\OrderedCollectionTest\OrderedCollectionTest.c
  Warning C4476: Unknown type field character '$' in format
                 specifier.
  Warning C4474: Too many arguments passed for format string.

3.StdLib\BsdSocketLib\getnetbyht.c
  Warning C4459: Declaration of 'net' hides global declaration.

4.StdLib\EfiSocketLib\Socket.c
  Warning C4459: Multiple declarations of 'errno' hide global
                 declaration.

5.AppPkg\Applications\Sockets\DataSource\DataSource.c
  Warning C4459: Declaration of 'BytesSent' hides global declaration.

6.AppPkg\Applications\Sockets\OobRx\OobRx.c
  Warning C4475: Length modifier 'L' cannot be used with type field
                 character 'd' in format specifier.

7.AppPkg\Applications\Sockets\RawIp4Rx\RawIp4Rx.c
  Warning C4475: Length modifier 'L' cannot be used with type field
                 character 'd' in format specifier.

8.StdLib\BsdSocketLib\ns_print.c
  Warning C4456: Multiple declarations of 't' hide previous local
                 declarations.
  Warning C4457: Declaration of 'type' hides function parameter.

Cc: Rebecca Cran <[email protected]>
Cc: Michael D Kinney <[email protected]>
Cc: Jayaprakash N <[email protected]>
Signed-off-by: Jayaprakash N <[email protected]>
Reviewed-by: Michael D Kinney <[email protected]>
  • Loading branch information
jpshivakavi committed Jul 22, 2024
1 parent caea801 commit fefde4a
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 107 deletions.
48 changes: 24 additions & 24 deletions AppPkg/Applications/Enquire/Enquire.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Steven Pemberton, CWI, Amsterdam; "[email protected]"
Used with permission.
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2024, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
Expand Down Expand Up @@ -918,15 +918,15 @@ memeq(
}

Void
farewell(int bugs)
farewell(int bugs_local)
{
if (bugs == 0) exit(0);
if (bugs_local == 0) exit(0);
printf("\n%sFor hints on dealing with the ", co);
if (bugs == 1) printf("problem");
else printf("%d problems", bugs);
if (bugs_local == 1) printf("problem");
else printf("%d problems", bugs_local);
printf(" above\n see the section 'TROUBLESHOOTING' in the file ");
printf("%s%s\n", FILENAME, oc);
exit(bugs);
exit(bugs_local);
}

/* The program has received a signal where it wasn't expecting one */
Expand Down Expand Up @@ -1927,51 +1927,51 @@ int cprop( void )

if (c_signed) {
#ifndef NO_UC
/* Syntax error? Define NO_UC */ Volatile unsigned char c1, char_max;
c1=0; char_max=0;
/* Syntax error? Define NO_UC */ Volatile unsigned char c1, char_max_local;
c1=0; char_max_local=0;
c1++;
if (setjmp(lab)==0) { /* Yields char_max */
while (c1>char_max) {
char_max=c1;
if (setjmp(lab)==0) { /* Yields char_max_local */
while (c1>char_max_local) {
char_max_local=c1;
c1++;
}
}
Unexpected(4);
if (sizeof(char) == sizeof(int)) {
u_define(D_UCHAR_MAX, "", "UCHAR", "_MAX",
(ulong) char_max,
(ulong) char_max_local,
(ulong) UCHAR_MAX, "");
} else {
i_define(D_UCHAR_MAX, "", "UCHAR", "_MAX",
(long) char_max, 0L,
(long) char_max_local, 0L,
(long) UCHAR_MAX, "");
}
#endif
} else {
#ifndef NO_SC
/* Syntax error? Define NO_SC */ Volatile signed char c1, char_max, char_min;
c1=0; char_max=0;
/* Syntax error? Define NO_SC */ Volatile signed char c1, char_max_local, char_min_local;
c1=0; char_max_local=0;
c1++;
if (setjmp(lab)==0) { /* Yields char_max */
while (c1>char_max) {
char_max=c1;
if (setjmp(lab)==0) { /* Yields char_max_local */
while (c1>char_max_local) {
char_max_local=c1;
c1++;
}
}
c1=0; char_min=0;
c1=0; char_min_local=0;
c1--;
if (setjmp(lab)==0) { /* Yields char_min */
while (c1<char_min) {
char_min=c1;
if (setjmp(lab)==0) { /* Yields char_min_local */
while (c1<char_min_local) {
char_min_local=c1;
c1--;
}
}
Unexpected(5);
i_define(D_SCHAR_MIN, "", "SCHAR", "_MIN",
(long) char_min, (long) maxint,
(long) char_min_local, (long) maxint,
(long) SCHAR_MIN, "");
i_define(D_SCHAR_MAX, "", "SCHAR", "_MAX",
(long) char_max, 0L,
(long) char_max_local, 0L,
(long) SCHAR_MAX, "");
#endif /* NO_SC */
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
per default, eg. serial line).
Copyright (C) 2014, Red Hat, Inc.
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2010 - 2024, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
Expand Down Expand Up @@ -458,18 +458,18 @@ SetupInputOutput (

case 'h':
fprintf (stderr,
"%1$s: simple OrderedCollectionLib tester\n"
"%s: simple OrderedCollectionLib tester\n"
"\n"
"Usage: 1. %1$s [-i InputFile] [-o OutputFile]\n"
" 2. %1$s -h\n"
"Usage: 1. %s [-i InputFile] [-o OutputFile]\n"
" 2. %s -h\n"
"\n"
"Options:\n"
" -i InputFile : read commands from InputFile\n"
" (will read from stdin if absent)\n"
" -o OutputFile: write command responses to OutputFile\n"
" (will write to stdout if absent)\n"
" -h : print this help and exit\n"
"\n", ArgV[0]);
"\n", ArgV[0], ArgV[0], ArgV[0]);
ListCommands ();
exit (EXIT_SUCCESS);

Expand Down
10 changes: 5 additions & 5 deletions AppPkg/Applications/Sockets/DataSource/DataSource.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
Data source for network testing.
Copyright (c) 2011-2012, Intel Corporation. All rights reserved.
Copyright (c) 2011 - 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
Expand Down Expand Up @@ -538,7 +538,7 @@ EFI_STATUS
SocketSend (
)
{
size_t BytesSent;
size_t BytesSentLocal;
EFI_STATUS Status;
EFI_TPL TplPrevious;

Expand All @@ -562,8 +562,8 @@ SocketSend (
//
// Send some bytes
//
BytesSent = write ( Socket, &Buffer[0], sizeof ( Buffer ));
if ( -1 == BytesSent ) {
BytesSentLocal = write ( Socket, &Buffer[0], sizeof ( Buffer ));
if ( -1 == BytesSentLocal ) {
DEBUG (( DEBUG_INFO,
"ERROR: send failed, errno: %d\r\n",
errno ));
Expand All @@ -589,7 +589,7 @@ Status = EFI_NOT_STARTED;
//
// Account for the data sent
//
TotalBytesSent += BytesSent;
TotalBytesSent += BytesSentLocal;

//
// Release the TimerCallback routine synchronization
Expand Down
6 changes: 3 additions & 3 deletions AppPkg/Applications/Sockets/OobRx/OobRx.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
Windows version of the OOB Receive application
Copyright (c) 2011-2012, Intel Corporation. All rights reserved.
Copyright (c) 2011 - 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
Expand Down Expand Up @@ -150,7 +150,7 @@ OobRx (
//
// Display the received OOB data
//
printf ( "%5Ld OOB bytes received\r\n", (UINT64)BytesReceived );
printf ( "%5llu OOB bytes received\r\n", (UINT64)BytesReceived );

//
// Account for the bytes received
Expand Down Expand Up @@ -183,7 +183,7 @@ OobRx (
//
// Display the received data
//
printf ( "%4Ld bytes received\r\n", (UINT64)BytesReceived );
printf ( "%4llu bytes received\r\n", (UINT64)BytesReceived );

//
// Account for the bytes received
Expand Down
4 changes: 2 additions & 2 deletions AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
Raw IP4 receive application
Copyright (c) 2011-2012, Intel Corporation. All rights reserved.
Copyright (c) 2011 - 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
Expand Down Expand Up @@ -157,7 +157,7 @@ RawIp4Rx (
// Display the bytes received
//
if ( 0 == RetVal ) {
printf ( "Total Bytes Received: %Ld\r\n", TotalBytesReceived );
printf ( "Total Bytes Received: %llu\r\n", TotalBytesReceived );
}

//
Expand Down
9 changes: 7 additions & 2 deletions StdLib/BsdSocketLib/getnetbyht.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
* from getnetent.c 1.1 (Coimbra) 93/06/02
*/

/*
* Copyright (c) 2023 - 2024, Intel Corporation. All rights reserved.
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/

#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93";
static char orig_rcsid[] = "From: Id: getnetent.c,v 8.4 1997/06/01 20:34:37 vixie Exp";
Expand Down Expand Up @@ -155,13 +160,13 @@ _getnetbyhtname(register const char *name)
}

struct netent *
_getnetbyhtaddr(register unsigned long net, register int type)
_getnetbyhtaddr(register unsigned long net_local, register int type)
{
register struct netent *p;

setnetent(_net_stayopen);
while ( NULL != (p = getnetent()) )
if (p->n_addrtype == type && p->n_net == net)
if (p->n_addrtype == type && p->n_net == net_local)
break;
if (!_net_stayopen)
endnetent();
Expand Down
Loading

0 comments on commit fefde4a

Please sign in to comment.