summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/blueshift_drm_c.c35
-rw-r--r--src/blueshift_iccprofile.c9
-rw-r--r--src/blueshift_idcrtc.c6
-rw-r--r--src/blueshift_randr_c.c2
4 files changed, 28 insertions, 24 deletions
diff --git a/src/blueshift_drm_c.c b/src/blueshift_drm_c.c
index ad6569c..368991a 100644
--- a/src/blueshift_drm_c.c
+++ b/src/blueshift_drm_c.c
@@ -25,12 +25,12 @@ static card_connection* card_connections = NULL;
/**
* Next card connection identifiers
*/
-static long card_connection_ptr = 0;
+static size_t card_connection_ptr = 0;
/**
* Size of the storage allocated for card connection resouces
*/
-static long card_connection_size = 0;
+static size_t card_connection_size = 0;
/**
* Card connection identifier reuse stack
@@ -40,12 +40,12 @@ static long* card_connection_reusables = NULL;
/**
* The head of `card_connection_reusables`
*/
-static long card_connection_reuse_ptr = 0;
+static size_t card_connection_reuse_ptr = 0;
/**
* The allocation size of `card_connection_reusables`
*/
-static long card_connection_reuse_size = 0;
+static size_t card_connection_reuse_size = 0;
@@ -162,7 +162,7 @@ void blueshift_drm_close_card(int connection)
free(card->connectors);
close(card->fd);
- if (connection + 1 == card_connection_reuse_ptr)
+ if ((size_t)connection + 1U == card_connection_reuse_ptr)
card_connection_reuse_ptr--;
else
{
@@ -233,11 +233,11 @@ int blueshift_drm_get_gamma_ramps(int connection, int crtc_index, int gamma_size
card_connection* card = card_connections + connection;
/* We need to initialise it to avoid valgrind warnings */
- memset(red, 0, gamma_size * sizeof(uint16_t));
- memset(green, 0, gamma_size * sizeof(uint16_t));
- memset(blue, 0, gamma_size * sizeof(uint16_t));
+ memset(red, 0, (size_t)gamma_size * sizeof(uint16_t));
+ memset(green, 0, (size_t)gamma_size * sizeof(uint16_t));
+ memset(blue, 0, (size_t)gamma_size * sizeof(uint16_t));
- return drmModeCrtcGetGamma(card->fd, *(card->res->crtcs + crtc_index), gamma_size, red, green, blue);
+ return drmModeCrtcGetGamma(card->fd, *(card->res->crtcs + crtc_index), (uint32_t)gamma_size, red, green, blue);
}
@@ -257,7 +257,7 @@ int blueshift_drm_set_gamma_ramps(int connection, int crtc_index, int gamma_size
card_connection* card = card_connections + connection;
/* Fails if inside a graphical environment */
- return drmModeCrtcSetGamma(card->fd, *(card->res->crtcs + crtc_index), gamma_size, red, green, blue);
+ return drmModeCrtcSetGamma(card->fd, *(card->res->crtcs + crtc_index), (uint32_t)gamma_size, red, green, blue);
}
@@ -272,7 +272,7 @@ void blueshift_drm_open_connector(int connection, int connector_index)
card_connection* card = card_connections + connection;
if (card->connectors == NULL)
- card->connectors = malloc(card->res->count_connectors * sizeof(drmModeConnector*));
+ card->connectors = malloc((size_t)(card->res->count_connectors) * sizeof(drmModeConnector*));
*(card->connectors + connector_index) = drmModeGetConnector(card->fd, *(card->res->connectors + connector_index));
}
@@ -299,7 +299,7 @@ void blueshift_drm_close_connector(int connection, int connector_index)
int blueshift_drm_get_width(int connection, int connector_index)
{
/* Accurate dimension on area not covered by the edges */
- return (card_connections + connection)->connectors[connector_index]->mmWidth;
+ return (int)((card_connections + connection)->connectors[connector_index]->mmWidth);
}
@@ -313,7 +313,7 @@ int blueshift_drm_get_width(int connection, int connector_index)
int blueshift_drm_get_height(int connection, int connector_index)
{
/* Accurate dimension on area not covered by the edges */
- return (card_connections + connection)->connectors[connector_index]->mmHeight;
+ return (int)((card_connections + connection)->connectors[connector_index]->mmHeight);
}
@@ -375,7 +375,7 @@ int blueshift_drm_get_crtc(int connection, int connector_index)
*/
int blueshift_drm_get_connector_type_index(int connection, int connector_index)
{
- return (card_connections + connection)->connectors[connector_index]->connector_type;
+ return (int)((card_connections + connection)->connectors[connector_index]->connector_type);
}
@@ -393,7 +393,7 @@ const char* blueshift_drm_get_connector_type_name(int connection, int connector_
"Unknown", "VGA", "DVII", "DVID", "DVIA", "Composite", "SVIDEO", "LVDS", "Component",
"9PinDIN", "DisplayPort", "HDMIA", "HDMIB", "TV", "eDP", "VIRTUAL", "DSI"};
- int type = ((card_connections + connection)->connectors[connector_index])->connector_type;
+ uint32_t type = ((card_connections + connection)->connectors[connector_index])->connector_type;
return (size_t)type < sizeof(TYPE_NAMES) / sizeof(char*) ? TYPE_NAMES[type] : "Unrecognised";
}
@@ -437,7 +437,10 @@ long blueshift_drm_get_edid(int connection, int connector_index, char* edid, lon
}
}
else
- memcpy(edid, blob->data, (blob->length < size ? blob->length : size) * sizeof(char));
+ {
+ uint32_t len = blob->length < size ? blob->length : size;
+ memcpy(edid, blob->data, (size_t)len * sizeof(char));
+ }
drmModeFreePropertyBlob(blob);
prop_i = connector->count_props; /* stop to for loop */
}
diff --git a/src/blueshift_iccprofile.c b/src/blueshift_iccprofile.c
index 7d97b9f..fb2aa7b 100644
--- a/src/blueshift_iccprofile.c
+++ b/src/blueshift_iccprofile.c
@@ -124,7 +124,7 @@ int main(int argc, char** argv)
xcb_get_atom_name_reply_t* name_reply;
char* name;
char* name_;
- int len;
+ size_t len;
xcb_get_property_cookie_t prop_cookie;
xcb_get_property_reply_t* prop_reply;
int monitor;
@@ -150,10 +150,11 @@ int main(int argc, char** argv)
/* Extract the atom name from the data structure that holds it. */
name_ = xcb_get_atom_name_name(name_reply);
/* As well as the length of the name; it is not NUL-termianted.*/
- len = xcb_get_atom_name_name_length(name_reply);
+ len = (size_t)xcb_get_atom_name_name_length(name_reply);
/* NUL-terminate the atom name, */
- name = alloca((len + 1) * sizeof(char)); /* It is allocated on the stack, so it should not be free:d */
+ name = alloca((len + 1U) * sizeof(char));
+ /* (it is allocated on the stack, so it should not be free:d) */
memcpy(name, name_, len * sizeof(char));
*(name + len) = 0;
/* and free the version that is not NUL-terminated. */
@@ -250,7 +251,7 @@ int main(int argc, char** argv)
char* value = alloca((2 * len + 1) * sizeof(char));
/* Get the property's value. */
char* value_ = xcb_get_property_value(prop_reply);
- int i;
+ size_t i;
/* Recode */
for (i = 0; i < len; i++)
diff --git a/src/blueshift_idcrtc.c b/src/blueshift_idcrtc.c
index 38bfebb..67ead56 100644
--- a/src/blueshift_idcrtc.c
+++ b/src/blueshift_idcrtc.c
@@ -294,8 +294,8 @@ int main(int argc, char** argv)
atom_name_len = xcb_get_atom_name_name_length(atom_name_reply);
/* NUL-terminate the atom name. */
- atom_name = alloca((atom_name_len + 1) * sizeof(char));
- memcpy(atom_name, atom_name_, atom_name_len * sizeof(char));
+ atom_name = alloca(((size_t)atom_name_len + 1U) * sizeof(char));
+ memcpy(atom_name, atom_name_, (size_t)atom_name_len * sizeof(char));
*(atom_name + atom_name_len) = 0;
/* (It is allocated on the stack, so it should not be free:d.) */
@@ -340,7 +340,7 @@ int main(int argc, char** argv)
length = xcb_randr_get_output_property_data_length(atom_reply);
/* Convert to hexadecimal representation. */
- atom_data = alloca((2 * length + 1) * sizeof(char));
+ atom_data = alloca((2U * (size_t)length + 1U) * sizeof(char));
for (i = 0; i < length; i++)
{
*(atom_data + i * 2 + 0) = "0123456789abcdef"[(*(atom_data_ + i) >> 4) & 15];
diff --git a/src/blueshift_randr_c.c b/src/blueshift_randr_c.c
index ddc19b9..fe3c708 100644
--- a/src/blueshift_randr_c.c
+++ b/src/blueshift_randr_c.c
@@ -206,7 +206,7 @@ uint16_t* blueshift_randr_read(int use_crtc)
G_gamma = xcb_randr_get_crtc_gamma_green(gamma_get_reply);
B_gamma = xcb_randr_get_crtc_gamma_blue(gamma_get_reply);
- r_gamma = malloc((3 + R_size + G_size + B_size) * sizeof(uint16_t));
+ r_gamma = malloc((3U + (size_t)R_size + (size_t)G_size + (size_t)B_size) * sizeof(uint16_t));
g_gamma = r_gamma + R_size + 1;
b_gamma = g_gamma + G_size + 1;
if (r_gamma == NULL)