Avoid null pointer deferefence

Improve code formatting
This commit is contained in:
Nazar 2019-04-12 17:16:55 +03:00
parent 10956702a5
commit 501d55bfc2
1 changed files with 14 additions and 14 deletions

View File

@ -1680,21 +1680,21 @@ struct wiringPiNodeStruct *wiringPiNewNode(int pinBase, int numPins) {
(void)wiringPiFailure(WPI_FATAL, "wiringPiNewNode: Pin %d overlaps with existing definition\n", pin);
node = (struct wiringPiNodeStruct *) calloc(sizeof (struct wiringPiNodeStruct), 1); // calloc zeros
if (node == NULL)
if (node == NULL) {
(void)wiringPiFailure(WPI_FATAL, "wiringPiNewNode: Unable to allocate memory: %s\n", strerror(errno));
node->pinBase = pinBase;
node->pinMax = pinBase + numPins - 1;
node->pinMode = pinModeDummy;
node->pullUpDnControl = pullUpDnControlDummy;
node->digitalRead = digitalReadDummy;
node->digitalWrite = digitalWriteDummy;
node->pwmWrite = pwmWriteDummy;
node->analogRead = analogReadDummy;
node->analogWrite = analogWriteDummy;
node->next = wiringPiNodes;
wiringPiNodes = node;
} else {
node->pinBase = pinBase;
node->pinMax = pinBase + numPins - 1;
node->pinMode = pinModeDummy;
node->pullUpDnControl = pullUpDnControlDummy;
node->digitalRead = digitalReadDummy;
node->digitalWrite = digitalWriteDummy;
node->pwmWrite = pwmWriteDummy;
node->analogRead = analogReadDummy;
node->analogWrite = analogWriteDummy;
node->next = wiringPiNodes;
wiringPiNodes = node;
}
return node;
}