Remove potentially unaligned uint32_t access in HIDParser.c, replace with standard C bit shifts.

This commit is contained in:
Dean Camera 2012-02-20 18:47:25 +00:00
parent 6c738343ae
commit 4068efbd18
9 changed files with 56 additions and 38 deletions

View file

@ -61,17 +61,18 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
switch (HIDReportItem & HID_RI_DATA_SIZE_MASK)
{
case HID_RI_DATA_BITS_32:
ReportItemData = le32_to_cpu(*((uint32_t*)ReportData));
ReportItemData = (((uint32_t)ReportData[3] << 24) | ((uint32_t)ReportData[2] << 16) |
((uint16_t)ReportData[1] << 8) | ReportData[0]);
ReportSize -= 4;
ReportData += 4;
break;
case HID_RI_DATA_BITS_16:
ReportItemData = le16_to_cpu(*((uint16_t*)ReportData));
ReportItemData = (((uint16_t)ReportData[1] << 8) | (ReportData[0]));
ReportSize -= 2;
ReportData += 2;
break;
case HID_RI_DATA_BITS_8:
ReportItemData = *((uint8_t*)ReportData);
ReportItemData = ReportData[0];
ReportSize -= 1;
ReportData += 1;
break;

View file

@ -233,7 +233,7 @@ static uint8_t AOA_Host_GetAccessoryProtocol(uint16_t* const Protocol)
static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
const uint8_t StringIndex)
{
const char* String = ((char**)&AOAInterfaceInfo->Config.PropertyStrings)[StringIndex];
const char* String = AOAInterfaceInfo->Config.PropertyStrings[StringIndex];
if (String == NULL)
String = "";

View file

@ -91,16 +91,8 @@
uint8_t DataOUTPipeNumber; /**< Pipe number of the AOA interface's OUT data pipe. */
bool DataOUTPipeDoubleBank; /**< Indicates if the AOA interface's OUT data pipe should use double banking. */
struct
{
char* Manufacturer; /**< Device manufacturer string. */
char* Model; /**< Device model name string. */
char* Description; /**< Device description string. */
char* Version; /**< Device version string. */
char* URI; /**< Device URI information string. */
char* Serial; /**< Device serial number string. */
} ATTR_PACKED PropertyStrings; /**< Android Accessory property strings, sent to identify the accessory when the
* Android device is switched into Open Accessory mode. */
char* PropertyStrings[AOA_STRING_TOTAL_STRINGS]; /**< Android Accessory property strings, sent to identify the accessory when the
* Android device is switched into Open Accessory mode. */
} Config; /**< Config data for the USB class interface within the device. All elements in this section
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
*/

View file

@ -278,7 +278,7 @@ uint8_t PRNT_Host_SendByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
}
uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
void* String)
const char* const String)
{
uint8_t ErrorCode;

View file

@ -190,7 +190,7 @@
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
*/
uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
void* String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
/** Sends the given raw data stream to the attached printer's input endpoint. This should contain commands that the
* printer is able to understand - for example, PCL data. Not all printers accept all printer languages; see