summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAmir Hammad <amir.hammad@hotmail.com>2016-09-08 06:27:35 +0200
committerAmir Hammad <amir.hammad@hotmail.com>2016-09-11 13:31:47 +0200
commit1d1b697bc6b13b5db1594c3dafe5452b6b2c1668 (patch)
tree5bf0ea2ffbf6536ce67d3e5b26d2b65e7c6a69ce /src
parentbc8dd60b2ebc311427c751937df464ba58b12c42 (diff)
downloadsecure-hid-1d1b697bc6b13b5db1594c3dafe5452b6b2c1668.tar.gz
secure-hid-1d1b697bc6b13b5db1594c3dafe5452b6b2c1668.tar.bz2
secure-hid-1d1b697bc6b13b5db1594c3dafe5452b6b2c1668.zip
use NULL instead of 0 for assigning null pointer
Signed-off-by: Amir Hammad <amir.hammad@hotmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/demo.c4
-rw-r--r--src/usbh_core.c15
-rw-r--r--src/usbh_driver_ac_midi.c8
-rw-r--r--src/usbh_driver_hid.c3
-rw-r--r--src/usbh_driver_hub.c3
5 files changed, 18 insertions, 15 deletions
diff --git a/src/demo.c b/src/demo.c
index 995e68c..44a94c0 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -119,7 +119,7 @@ static const usbh_dev_driver_t *device_drivers[] = {
&usbh_hid_driver,
&usbh_gp_xbox_driver,
&usbh_midi_driver,
- 0
+ NULL
};
static void gp_xbox_update(uint8_t device_id, gp_xbox_packet_t packet)
@@ -234,7 +234,7 @@ int main(void)
#ifdef USE_STM32F4_USBH_DRIVER_HS
usbh_lld_stm32f4_driver_hs, // Make sure USE_STM32F4_USBH_DRIVER_HS is defined in usbh_config.h
#endif
- 0
+ NULL
};
usbh_init(lld_drivers, device_drivers);
gpio_clear(GPIOD, GPIO13);
diff --git a/src/usbh_core.c b/src/usbh_core.c
index fd1dca5..5448d6c 100644
--- a/src/usbh_core.c
+++ b/src/usbh_core.c
@@ -35,7 +35,7 @@ static struct {
const usbh_low_level_driver_t * const *lld_drivers;
const usbh_dev_driver_t * const *dev_drivers;
int8_t address_temporary;
-} usbh_data = {0};
+} usbh_data = {};
static void set_enumeration(void)
{
@@ -58,8 +58,8 @@ void device_remove(usbh_device_t *dev)
dev->drv->remove(dev->drvdata);
}
dev->address = -1;
- dev->drv = 0;
- dev->drvdata = 0;
+ dev->drv = NULL;
+ dev->drvdata = NULL;
}
/**
@@ -105,11 +105,10 @@ static bool find_driver(usbh_device_t *dev, const usbh_dev_driver_info_t * devic
static void device_register(void *descriptors, uint16_t descriptors_len, usbh_device_t *dev)
{
uint32_t i = 0;
- dev->drv = 0;
uint8_t *buf = (uint8_t *)descriptors;
- dev->drv = 0;
- dev->drvdata = 0;
+ dev->drv = NULL;
+ dev->drvdata = NULL;
uint8_t desc_len = buf[i];
uint8_t desc_type = buf[i + 1];
@@ -285,7 +284,7 @@ static void control_state_machine(usbh_device_t *dev, usbh_packet_callback_data_
} else {
if (dev->control.data_length == 0) {
dev->control.state = USBH_CONTROL_STATE_STATUS;
- device_xfer_control_read(0, 0, control_state_machine, dev);
+ device_xfer_control_read(NULL, 0, control_state_machine, dev);
} else {
dev->control.state = USBH_CONTROL_STATE_DATA;
device_xfer_control_write_data(dev->control.data.out, dev->control.data_length, control_state_machine, dev);
@@ -315,7 +314,7 @@ static void control_state_machine(usbh_device_t *dev, usbh_packet_callback_data_
dev->control.callback(dev, cb_data);
} else {
dev->control.state = USBH_CONTROL_STATE_STATUS;
- device_xfer_control_read(0, 0, control_state_machine, dev);
+ device_xfer_control_read(NULL, 0, control_state_machine, dev);
}
}
break;
diff --git a/src/usbh_driver_ac_midi.c b/src/usbh_driver_ac_midi.c
index 0a747f7..9d139d5 100644
--- a/src/usbh_driver_ac_midi.c
+++ b/src/usbh_driver_ac_midi.c
@@ -24,6 +24,8 @@
#include "usbh_driver_ac_midi_private.h"
#include "usart_helpers.h"
+#include <stddef.h>
+
#include <libopencm3/usb/midi.h>
#include <libopencm3/usb/audio.h>
#include <libopencm3/usb/usbstd.h>
@@ -35,7 +37,7 @@ static void poll(void *drvdata, uint32_t tflp);
static void remove(void *drvdata);
static midi_device_t midi_device[USBH_AC_MIDI_MAX_DEVICES];
-static const midi_config_t *midi_config = 0;
+static const midi_config_t *midi_config = NULL;
static bool initialized = false;
static const usbh_dev_driver_info_t usbh_midi_driver_info = {
@@ -77,7 +79,7 @@ static void *init(void *usbh_dev)
return 0;
}
uint32_t i;
- midi_device_t *drvdata = 0;
+ midi_device_t *drvdata = NULL;
// find free data space for midi device
for (i = 0; i < USBH_AC_MIDI_MAX_DEVICES; i++) {
@@ -89,7 +91,7 @@ static void *init(void *usbh_dev)
drvdata->endpoint_in_toggle = 0;
drvdata->endpoint_out_toggle = 0;
drvdata->usbh_device = usbh_dev;
- drvdata->write_callback_user = 0;
+ drvdata->write_callback_user = NULL;
drvdata->sending = false;
break;
}
diff --git a/src/usbh_driver_hid.c b/src/usbh_driver_hid.c
index 54956b2..0e90ab0 100644
--- a/src/usbh_driver_hid.c
+++ b/src/usbh_driver_hid.c
@@ -28,6 +28,7 @@
#include <libopencm3/usb/usbstd.h>
#include <libopencm3/usb/hid.h>
#include <stdint.h>
+#include <stddef.h>
#define USB_HID_SET_REPORT 0x09
#define USB_HID_SET_IDLE 0x0A
@@ -100,7 +101,7 @@ static void *init(void *usbh_dev)
}
uint32_t i;
- hid_device_t *drvdata = 0;
+ hid_device_t *drvdata = NULL;
// find free data space for HID device
for (i = 0; i < USBH_HID_MAX_DEVICES; i++) {
diff --git a/src/usbh_driver_hub.c b/src/usbh_driver_hub.c
index 7dc99ea..2127158 100644
--- a/src/usbh_driver_hub.c
+++ b/src/usbh_driver_hub.c
@@ -25,6 +25,7 @@
#include "usart_helpers.h"
#include "usbh_config.h"
+#include <stddef.h>
#include <stdint.h>
static hub_device_t hub_device[USBH_MAX_HUBS];
@@ -52,7 +53,7 @@ static void *init(void *usbh_dev)
}
uint32_t i;
- hub_device_t *drvdata = 0;
+ hub_device_t *drvdata = NULL;
// find free data space for hub device
for (i = 0; i < USBH_MAX_HUBS; i++) {
if (hub_device[i].device[0] == 0) {