mirror of https://github.com/nirenjan/libx52.git
Reduce variable scope as suggested by code inspector
parent
95bc71859b
commit
780d9b4da4
|
@ -109,7 +109,6 @@ int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value)
|
||||||
static int _x52_write_line(libx52_device *x52, uint8_t line_index)
|
static int _x52_write_line(libx52_device *x52, uint8_t line_index)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint16_t value;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
const uint16_t line_index_map[X52_MFD_LINES] = {
|
const uint16_t line_index_map[X52_MFD_LINES] = {
|
||||||
|
@ -126,6 +125,7 @@ static int _x52_write_line(libx52_device *x52, uint8_t line_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < x52->line[line_index].length; i += 2) {
|
for (i = 0; i < x52->line[line_index].length; i += 2) {
|
||||||
|
uint16_t value;
|
||||||
value = x52->line[line_index].text[i + 1] << 8 |
|
value = x52->line[line_index].text[i + 1] << 8 |
|
||||||
x52->line[line_index].text[i];
|
x52->line[line_index].text[i];
|
||||||
|
|
||||||
|
@ -180,11 +180,12 @@ static int _x52_write_time(libx52_device *x52, libx52_clock_id clock)
|
||||||
{
|
{
|
||||||
uint16_t value = 0;
|
uint16_t value = 0;
|
||||||
uint16_t index;
|
uint16_t index;
|
||||||
int offset;
|
|
||||||
int negative;
|
|
||||||
uint16_t h24 = !!(x52->time_format[clock]);
|
uint16_t h24 = !!(x52->time_format[clock]);
|
||||||
|
|
||||||
if (clock != LIBX52_CLOCK_1) {
|
if (clock != LIBX52_CLOCK_1) {
|
||||||
|
int offset;
|
||||||
|
int negative;
|
||||||
|
|
||||||
offset = x52->timezone[clock] - x52->timezone[LIBX52_CLOCK_1];
|
offset = x52->timezone[clock] - x52->timezone[LIBX52_CLOCK_1];
|
||||||
|
|
||||||
/* Save the preliminary state, if negative, set the negative flag */
|
/* Save the preliminary state, if negative, set the negative flag */
|
||||||
|
|
|
@ -65,7 +65,6 @@ int libx52_connect(libx52_device *dev)
|
||||||
ssize_t count;
|
ssize_t count;
|
||||||
int i;
|
int i;
|
||||||
libusb_device **list;
|
libusb_device **list;
|
||||||
libusb_device *device;
|
|
||||||
libusb_device_handle *hdl;
|
libusb_device_handle *hdl;
|
||||||
struct libusb_device_descriptor desc;
|
struct libusb_device_descriptor desc;
|
||||||
|
|
||||||
|
@ -84,6 +83,8 @@ int libx52_connect(libx52_device *dev)
|
||||||
|
|
||||||
count = libusb_get_device_list(dev->ctx, &list);
|
count = libusb_get_device_list(dev->ctx, &list);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
|
libusb_device *device;
|
||||||
|
|
||||||
device = list[i];
|
device = list[i];
|
||||||
if (!libusb_get_device_descriptor(device, &desc)) {
|
if (!libusb_get_device_descriptor(device, &desc)) {
|
||||||
if (libx52_check_product(desc.idVendor, desc.idProduct)) {
|
if (libx52_check_product(desc.idVendor, desc.idProduct)) {
|
||||||
|
|
Loading…
Reference in New Issue