Fix wrong pointer -replace and small cleanup.

This commit is contained in:
Qball Cow
2025-02-09 11:00:59 +01:00
parent f43d578264
commit 995cd3c048
3 changed files with 8 additions and 9 deletions

View File

@@ -583,7 +583,7 @@ int create_pid_file(const char *pidfile, gboolean kill_running) {
char buffer[64] = {
0,
};
ssize_t l = read(fd, &buffer, 63);
ssize_t l = read(fd, &(buffer[0]), 63);
if (l > 1) {
buffer[l] = 0;
pid_t pid = g_ascii_strtoll(buffer, NULL, 0);

View File

@@ -286,8 +286,8 @@ static gpointer read_input_thread(gpointer userdata) {
if (FD_ISSET(fd, &rfds)) {
ssize_t readbytes = 0;
if ((nread + 1024) > len) {
line = g_realloc(line, (nread + 1024));
len = nread + 1024;
line = g_realloc(line, (len + 2048));
len = len + 2048;
}
readbytes = read(fd, &line[nread], 1023);
if (readbytes > 0) {

View File

@@ -254,7 +254,7 @@ textbox *textbox_create(widget *parent, WidgetType type, const char *name,
const char *password_mask_char =
rofi_theme_get_string(WIDGET(tb), "password-mask", NULL);
if (password_mask_char == NULL || (*password_mask_char) == '\0'){
if (password_mask_char == NULL || (*password_mask_char) == '\0') {
tb->password_mask_char = "*";
} else {
tb->password_mask_char = password_mask_char;
@@ -350,7 +350,7 @@ static void __textbox_update_pango_text(textbox *tb) {
size_t mask_len = strlen(tb->password_mask_char);
char string[text_len * mask_len + 1];
for (size_t offset = 0; offset < text_len * mask_len; offset += mask_len) {
memcpy(string + offset, tb->password_mask_char, mask_len);
memcpy(string + offset, tb->password_mask_char, mask_len);
}
string[text_len * mask_len] = '\0';
pango_layout_set_text(tb->layout, string, -1);
@@ -501,7 +501,6 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
return;
}
textbox *tb = (textbox *)wid;
int dot_offset = 0;
if (tb->changed) {
__textbox_update_pango_text(tb);
@@ -534,7 +533,7 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
{
int rem =
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
line_width - dot_offset);
line_width);
switch (pango_layout_get_alignment(tb->layout)) {
case PANGO_ALIGN_CENTER:
x = rem * (tb->xalign - 0.5);
@@ -543,7 +542,7 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
x = rem * (tb->xalign - 1.0);
break;
default:
x = rem * tb->xalign + dot_offset;
x = rem * tb->xalign;
break;
}
x += widget_padding_get_left(WIDGET(tb));