From 413ff0c6eb83fc603f96f870769e50c6234bd171 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 7 Mar 2020 11:31:12 +0100 Subject: Fix openpixelcontrol edge case --- backends/openpixelcontrol.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'backends') diff --git a/backends/openpixelcontrol.c b/backends/openpixelcontrol.c index d9d7d4b..b5885b0 100644 --- a/backends/openpixelcontrol.c +++ b/backends/openpixelcontrol.c @@ -1,4 +1,5 @@ #define BACKEND_NAME "openpixelcontrol" +#define DEBUG #include @@ -422,10 +423,9 @@ static ssize_t openpixel_client_pixeldata(instance* inst, openpixel_client* clie //ignore data if(client->buffer == -2){ //ignore data - u = min(client->left, bytes_left); - client->offset += u; - client->left -= u; - return u; + client->offset += bytes_left; + client->left -= bytes_left; + return bytes_left; } //handle broadcast data else if(client->buffer == -3){ @@ -559,7 +559,7 @@ static int openpixel_client_handle(instance* inst, int fd){ } else{ //read data - bytes_handled = openpixel_client_pixeldata(inst, data->client + c, buffer + offset, bytes_left); + bytes_handled = openpixel_client_pixeldata(inst, data->client + c, buffer + offset, min(bytes_left, data->client[c].left)); if(bytes_handled < 0){ //FIXME handle errors } -- cgit v1.2.3