From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.19716.1611805684329162406 for ; Wed, 27 Jan 2021 19:48:04 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=S3w3QnIy; spf=pass (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=0662e9a25a=abner.chang@hpe.com) Received: from pps.filterd (m0134422.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 10S3XBZ8026407; Thu, 28 Jan 2021 03:48:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=oVGtlyvKnMTl8tgcVyvvZH7E/wxF4BWekxtIV9OFpiw=; b=S3w3QnIyBc7rCEAeR+sJnw7uB77SHd0AVPSQYOqkbnTQ8jMw6gxNVOqM1mL8LcPPfZZ3 z+X4NuwhnL0NcBRnU61DT/I/b8IX3YHjzQJT88CbEm99cjHDZKyaPC9XHajZsjluQ2mC qzAlmGag3YLK7oc6TaZBOyh0jcBGJMA3PcmMG2FqcOTIDAu82wbTgb6mphapbUTc/k9u hMUjs3dZtMDPlsE91+mdJd9KdQrRNdUYKwUuegSjtRbpQTKnytJScICl9h7kqQ1jYYVB cU+9jZf8QrV+iWiFuoXZyYS9UUO4/7DWe4jJ/tStyW+tG/bMGjzOgftrcJcg6FnMSSAa lg== Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 36b0x7s2cn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jan 2021 03:48:03 +0000 Received: from G4W10205.americas.hpqcorp.net (g4w10205.houston.hpecorp.net [16.207.82.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2352.austin.hpe.com (Postfix) with ESMTPS id DBD4BB5; Thu, 28 Jan 2021 03:48:02 +0000 (UTC) Received: from G9W9210.americas.hpqcorp.net (2002:10dc:429b::10dc:429b) by G4W10205.americas.hpqcorp.net (2002:10cf:520f::10cf:520f) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 28 Jan 2021 03:48:02 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (15.241.52.12) by G9W9210.americas.hpqcorp.net (16.220.66.155) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 28 Jan 2021 03:48:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RBwa8mHrti52/gzAEo6r5vipSvRDh1w+s66PwMd+RDrJmBhB2W90dcbH2zz0Sd8ZNz4CC0dp04NKA/E9X3qHjL6xrSXpA4kHO2pwwch6pxiGJbSrtOJ2hYxs0BODc7/rJkQXksG3PRsoQ7mUUqiflSP3UZdzd8IgelJsIUMgJml8K+FUpUAnFPkOIsx+Nu4mxf/p4x7l2Tp3nejSAwdk7Ao3NYYFKcjtkPB+WGMrlh20s90J0t8orvmNLfWmFYoeL+x5/0Ox159/5bcw0m9pDm075xs27TUZWveUXRVDeGypcsZrahuaGpsI82LOYVWfhUpNoeRS8n14pGr9PtJKNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8y1u3E7zkXMmfzepTOWjIQXrY7+MZ4N0Wyq364M0ue4=; b=HH404INkLVU61EEofjBeU4LoqyvquT3lpZyXNvt9yxDc57llfws2uAMb5B+7O9cxN1Ej94BsbOUJ3Gj+LBmhDxNANOMvMDk0u/o34Gnd9tcxplFetp979dHgjfQfGkMDyurEa2fiCG83yIYyLfAkk1e5V6KE7eOt+EK67TlfO9UR2TgJ6rr8CwfkVy3Izr8AZe70erpnlOqiRZnrns1SJYs9lwxBVLiiZC5y0d4cJvRZ7Jd5u5ZQOobh44emucIgUqEC/5O6m+UTAMpdDgsXE5d+zQ6tsePRwIn8FmNWdjVXXCQGkUXzYgggefp1/YuySpncQei5ruXnF+HhoXR0yA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7508::16) by CS1PR8401MB0709.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:750c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.15; Thu, 28 Jan 2021 03:48:00 +0000 Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::adb6:a875:93ca:b54a]) by CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::adb6:a875:93ca:b54a%12]) with mapi id 15.20.3784.019; Thu, 28 Jan 2021 03:48:00 +0000 From: "Abner Chang" To: Leif Lindholm CC: "devel@edk2.groups.io" , "Wang, Nickle (HPS SW)" , Michael D Kinney Subject: Re: [PATCH] RedfishPkg/RedfishCrtLib: Add more CRT functions Thread-Topic: [PATCH] RedfishPkg/RedfishCrtLib: Add more CRT functions Thread-Index: AQHW89eM4AHD5QipRkuPmmC8iDXQWKo8aL0g Date: Thu, 28 Jan 2021 03:48:00 +0000 Message-ID: References: <20210125043653.20832-1-abner.chang@hpe.com> <20210126113646.GP1664@vanye> In-Reply-To: <20210126113646.GP1664@vanye> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: nuviainc.com; dkim=none (message not signed) header.d=none;nuviainc.com; dmarc=none action=none header.from=hpe.com; x-originating-ip: [16.242.247.131] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: f1f8502a-7e53-48d6-bd9d-08d8c33f8217 x-ms-traffictypediagnostic: CS1PR8401MB0709: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PgfDv2ZWXwatteoSq+qM2jRxzWJP4I/gmB+BMxoMigBTk4w7jjwtAdQCmKTemPizDV7wEXD5s1D/z9W2SvUZ2LJWj518FzrsIjZupkH5vlsVmZ6rPIiD361ks/zukxMvLfYp3gEtIAeuRNWVRXWundl8S+xGzPyNA76AwZoN3ICaDEF2OIj4KLrK2blgkn5iREPOBYGT8hwF8D19FfJthvcWjbkSz7sChbMmwvdr3wzglL3ZT9acMq0611L/CuaccncXeUCfQc3uD23c0cY6QGzk5BX+m9UBjI37RcXiT2SF+zno/mo4KRGRuwLiCuuK93nfuOZ1L/fIIpJW2nybBjs8s58zbAL5eVCM+VtsZ6jmjCYR2bJNyXOwhK5HarPODXhVLqDNH33C5GrCw+xfFg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(136003)(396003)(346002)(366004)(376002)(39860400002)(66476007)(2906002)(64756008)(6916009)(54906003)(66446008)(7696005)(8936002)(8676002)(66556008)(66946007)(86362001)(316002)(76116006)(9686003)(33656002)(83380400001)(53546011)(55016002)(5660300002)(4326008)(52536014)(186003)(26005)(478600001)(6506007)(71200400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?E8sUism5h4arpAF46PA7q+18gYq5xQ+TXzu1thWw73bUNdxfu/vVjP4Ulpkx?= =?us-ascii?Q?4OJrrh94VBgOm6vKXlOvXS3SoRRAwiqN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?9LyNXKiSmWuqncu2C4z7sHmh1RAhNwclQTuwCJc+hnQW6SxYShAOpbUkhBIV?= =?us-ascii?Q?z+rU9a8khV8tTXVgmkGvYPDWlE8X6NAWdH9Jboivgns7dLNn0FbE+iWFFITo?= =?us-ascii?Q?ON/e57Zy?= X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: f1f8502a-7e53-48d6-bd9d-08d8c33f8217 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jan 2021 03:48:00.5215 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7bqPw9/yb4dh5NrrWwF3WyV14LtNvbo9wz7XVz0vQMMAPkeO1mw/MFee1oN50qPKpFumkp6EH7kfP5lSDiKVNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR8401MB0709 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-28_01:2021-01-27,2021-01-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 adultscore=0 bulkscore=0 mlxscore=0 clxscore=1015 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101280017 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable All fixed and v2 sent. Didn't pay attention on the return values. Thanks fo= r catching this. Abner > -----Original Message----- > From: Leif Lindholm [mailto:leif@nuviainc.com] > Sent: Tuesday, January 26, 2021 7:37 PM > To: Chang, Abner (HPS SW/FW Technologist) > Cc: devel@edk2.groups.io; Wang, Nickle (HPS SW) ; > Michael D Kinney > Subject: Re: [PATCH] RedfishPkg/RedfishCrtLib: Add more CRT functions >=20 > On Mon, Jan 25, 2021 at 12:36:53 +0800, Abner Chang wrote: > > Add more functions which were missed in the first time commit, that > > causes the build error with EDK2 Redfish feature driver. > > > > strerror - We don't support this on edk2 environment. > > strpbrk - Cloned this function from edk2-LibC File operation > > functions - Not supported on edk2 environment. > > > > Signed-off-by: Abner Chang > > > > Cc: Nickle Wang > > Cc: Leif Lindholm > > Cc: Michael D Kinney > > --- > > .../RedfishCrtLib/RedfishCrtLib.c | 119 ++++++++++++++++++ > > 1 file changed, 119 insertions(+) > > > > diff --git a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > > b/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > > index 0696341bc0..c64f14534c 100644 > > --- a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > > +++ b/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > > @@ -15,6 +15,10 @@ > > #include > > > > int errno =3D 0; > > +char errnum_message [] =3D "We don't support to map errnum to the error > > +message on edk2 Redfish\n"; > > + > > +// This is required to keep VC++ happy if you use floating-point int > > +_fltused =3D 1; > > > > /** > > Determine if a particular character is an alphanumeric character @@ > > -465,6 +469,76 @@ strtod (const char * __restrict nptr, char ** __restr= ict > endptr) { > > return (double)0; > > } > > > > +static UINT8 BitMask[] =3D { > > + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 > > + }; > > + > > +#define WHICH8(c) ((unsigned char)(c) >> 3) > > +#define WHICH_BIT(c) (BitMask[((c) & 0x7)]) > > +#define BITMAP64 ((UINT64 *)bitmap) > > + > > +static > > +void > > +BuildBitmap(unsigned char * bitmap, const char *s2, int n) { > > + unsigned char bit; > > + int index; > > + > > + // Initialize bitmap. Bit 0 is always 1 which corresponds to '\0' > > + for (BITMAP64[0] =3D index =3D 1; index < n; index++) > > + BITMAP64[index] =3D 0; >=20 > Please use {}. >=20 > > + > > + // Set bits in bitmap corresponding to the characters in s2 > > + for (; *s2 !=3D '\0'; s2++) { > > + index =3D WHICH8(*s2); > > + bit =3D WHICH_BIT(*s2); > > + bitmap[index] =3D bitmap[index] | bit; > > + } > > +} > > + > > +/** The strpbrk function locates the first occurrence in the string po= inted > to > > + by s1 of any character from the string pointed to by s2. > > + > > + @return The strpbrk function returns a pointer to the character,= or a > > + null pointer if no character from s2 occurs in s1. > > +**/ > > +char * > > +strpbrk(const char *s1, const char *s2) { > > + UINT8 bitmap[ (((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & > > +~7U]; > > + UINT8 bit; > > + int index; > > + > > + BuildBitmap( bitmap, s2, sizeof(bitmap) / sizeof(UINT64)); > > + > > + for( ; *s1 !=3D '\0'; ++s1) { > > + index =3D WHICH8(*s1); > > + bit =3D WHICH_BIT(*s1); > > + if( (bitmap[index] & bit) !=3D 0) { > > + return (char *)s1; > > + } > > + } > > + return NULL; > > +} > > + > > +/** The strerror function maps the number in errnum to a message strin= g. > > + Typically, the values for errnum come from errno, but strerror sha= ll map > > + any value of type int to a message. > > + > > + The implementation shall behave as if no library function calls the > > + strerror function. > > + > > + @return The strerror function returns a pointer to the string, t= he > > + contents of which are locale specific. The array pointe= d to > > + shall not be modified by the program, but may be overwri= tten by > > + a subsequent call to the strerror function. > > +**/ > > +char * > > +strerror(int errnum) > > +{ > > + return errnum_message; > > +} > > + > > /** > > Allocate and zero-initialize array. > > **/ > > @@ -594,6 +668,51 @@ void qsort (void *base, size_t num, size_t width, > > int (*compare)(const void *, c int fgetc(FILE * _File){ > > return 0; > > } > > +/** > > + Open stream file, we don't support file operastion on edk2 JSON libr= ary. > > + > > + @return 0 Unsupported > > + > > +**/ > > +FILE *fopen (const char *filename, const char *mode) { > > + return 0; >=20 > NULL. >=20 > > +} > > +/** > > + Read stream from file, we don't support file operastion on edk2 JSON > library. > > + > > + @return 0 Unsupported > > + > > +**/ > > +size_t fread (void * ptr, size_t size, size_t count, FILE * stream) { > > + return 0; > > +} > > +/** > > + Write stream from file, we don't support file operastion on edk2 JSON > library. > > + > > + @return 0 Unsupported > > + > > +**/ > > +size_t fwrite (const void * ptr, size_t size, size_t count, FILE * > > +stream) { > > + return 0; > > +} > > +/** > > + Close file, we don't support file operastion on edk2 JSON library. > > + > > + @return 0 Unsupported > > + > > +**/ > > +int fclose (FILE * stream) { > > + return 0; >=20 > 0 indicated success. EOF should be returned otherwise. >=20 > > +} > > +/** > > + Write the formatted string to file, we don't support file operastion= on > edk2 JSON library. > > + > > + @return 0 Unsupported > > + > > +**/ > > +int fprintf (FILE * stream, const char * format, ...) { > > + return 0; >=20 > From my linux manpage: > "If an output error is encountered, a negative value is returned." >=20 > / > Leif >=20 > > +} > > /** > > This function check if this is the formating string specifier. > > > > -- > > 2.17.1 > >