Fix pal_io.c code based on code review suggestions (#34970)
authorOmair Majid <omajid@redhat.com>
Wed, 15 Apr 2020 12:23:20 +0000 (08:23 -0400)
committerGitHub <noreply@github.com>
Wed, 15 Apr 2020 12:23:20 +0000 (08:23 -0400)
These suggestions were provided by @lpereira on
https://github.com/dotnet/corefx/pull/42900

src/libraries/Native/Unix/System.Native/pal_io.c

index 6090846..4c5af27 100644 (file)
@@ -932,15 +932,15 @@ int32_t SystemNative_Poll(PollEvent* pollEvents, uint32_t eventCount, int32_t mi
     }
 
     struct pollfd stackBuffer[(uint32_t)(2048/sizeof(struct pollfd))];
-    int useStackBuffer = eventCount <= (sizeof(stackBuffer)/sizeof(stackBuffer[0]));
+    int useStackBuffer = eventCount <= ARRAY_SIZE(stackBuffer);
     struct pollfd* pollfds = NULL;
     if (useStackBuffer)
     {
-        pollfds = (struct pollfd*)&stackBuffer[0];
+        pollfds = &stackBuffer[0];
     }
     else
     {
-        pollfds = (struct pollfd*)calloc(eventCount, sizeof(*pollfds));
+        pollfds = calloc(eventCount, sizeof(*pollfds));
         if (pollfds == NULL)
         {
             return Error_ENOMEM;