mirror of
https://github.com/javalsai/lidm.git
synced 2025-07-03 06:15:03 +02:00
chore: use size_t
for indexing and iterating
This commit is contained in:
parent
e13a8ff79c
commit
f34a71195e
@ -3,6 +3,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "keys.h"
|
||||
@ -25,6 +26,6 @@ void vec_free(struct Vector*);
|
||||
void vec_clear(struct Vector*);
|
||||
void vec_reset(struct Vector*);
|
||||
void* vec_pop(struct Vector*); // won't free it, nor shrink vec list space
|
||||
void* vec_get(struct Vector*, uint32_t index);
|
||||
void* vec_get(struct Vector*, size_t index);
|
||||
|
||||
#endif
|
||||
|
10
src/auth.c
10
src/auth.c
@ -19,7 +19,7 @@ int pam_conversation(int num_msg, const struct pam_message **msg,
|
||||
struct pam_response **resp, void *appdata_ptr) {
|
||||
struct pam_response *reply =
|
||||
(struct pam_response *)malloc(sizeof(struct pam_response) * num_msg);
|
||||
for (int i = 0; i < num_msg; i++) {
|
||||
for (size_t i = 0; i < num_msg; i++) {
|
||||
reply[i].resp = NULL;
|
||||
reply[i].resp_retcode = 0;
|
||||
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF ||
|
||||
@ -79,7 +79,7 @@ void sourceFileTry(char *file) {
|
||||
|
||||
/* printf("Retrieved line of length %zu:\n", read); */
|
||||
/* printf("%s\n", line); */
|
||||
for (uint i = 1; i < read; i++) {
|
||||
for (size_t i = 1; i < read; i++) {
|
||||
if (line[i] == '=') {
|
||||
/* printf("FOUND '='!\n"); */
|
||||
line[i] = '\0';
|
||||
@ -118,7 +118,7 @@ void moarEnv(char *user, struct session session, struct passwd *pw,
|
||||
setenv("XDG_SESSION_TYPE", xdg_session_type, true);
|
||||
|
||||
printf("\n\n\n\n\x1b[1m");
|
||||
for (uint32_t i = 0; i < behavior->source.length; i++) {
|
||||
for (size_t i = 0; i < behavior->source.length; i++) {
|
||||
/* printf("DEBUG(source)!!!! %d %s\n", i, (char*)vec_get(&behavior->source,
|
||||
* i)); */
|
||||
sourceFileTry((char *)vec_get(&behavior->source, i));
|
||||
@ -126,7 +126,7 @@ void moarEnv(char *user, struct session session, struct passwd *pw,
|
||||
/* printf("\n"); */
|
||||
if (pw->pw_dir) {
|
||||
uint home_len = strlen(pw->pw_dir);
|
||||
for (uint32_t i = 0; i < behavior->user_source.length; i++) {
|
||||
for (size_t i = 0; i < behavior->user_source.length; i++) {
|
||||
char *file2sourcepath = (char *)vec_get(&behavior->user_source, i);
|
||||
char *newbuf =
|
||||
malloc(home_len + strlen(file2sourcepath) + 2); // nullbyte and slash
|
||||
@ -190,7 +190,7 @@ bool launch(char *user, char *passwd, struct session session, void (*cb)(void),
|
||||
print_errno("pam_getenvlist");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
for (uint i = 0; envlist[i] != NULL; i++) {
|
||||
for (size_t i = 0; envlist[i] != NULL; i++) {
|
||||
putenv(envlist[i]);
|
||||
}
|
||||
// FIXME: path hotfix
|
||||
|
@ -26,7 +26,7 @@ int chvt_str(char *str) {
|
||||
int chvt(int n) {
|
||||
fprintf(stderr, "activating vt %d\n", n);
|
||||
char c = 0;
|
||||
for (int i = 0; i < sizeof(vterms) / sizeof(vterms[0]); i++) {
|
||||
for (size_t i = 0; i < sizeof(vterms) / sizeof(vterms[0]); i++) {
|
||||
int fd = open(vterms[i], O_RDWR);
|
||||
if (fd >= 0 && isatty(fd) && ioctl(fd, KDGKBTYPE, &c) == 0 && c < 3) {
|
||||
if (ioctl(fd, VT_ACTIVATE, n) < 0 || ioctl(fd, VT_WAITACTIVE, n) < 0) {
|
||||
|
@ -110,7 +110,7 @@ struct Vector get_avaliable_sessions() {
|
||||
struct Vector sessions = vec_new();
|
||||
|
||||
cb_sessions = &sessions;
|
||||
for (uint i = 0; i < (sizeof(sources) / sizeof(sources[0])); i++) {
|
||||
for (size_t i = 0; i < (sizeof(sources) / sizeof(sources[0])); i++) {
|
||||
/*printf("recurring into %s\n", sources[i].dir);*/
|
||||
session_type = sources[i].type;
|
||||
ftw(sources[i].dir, &fn, 1);
|
||||
|
6
src/ui.c
6
src/ui.c
@ -500,15 +500,15 @@ static void print_passwd(struct uint_point origin, uint length, bool err) {
|
||||
}
|
||||
|
||||
static void print_empty_row(uint w, uint n, char *edge1, char *edge2) {
|
||||
for (uint i = 0; i < n; i++) {
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
printf("%s\x1b[%dC%s\x1b[%dD\x1b[1B", edge1, w, edge2, w + 2);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_row(uint w, uint n, char *edge1, char *edge2, char *filler) {
|
||||
for (uint i = 0; i < n; i++) {
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
printf("%s", edge1);
|
||||
for (uint i = 0; i < w; i++) {
|
||||
for (size_t i = 0; i < w; i++) {
|
||||
printf("%s", filler);
|
||||
}
|
||||
printf("%s\x1b[%dD\x1b[1B", edge2, w + 2);
|
||||
|
@ -119,7 +119,7 @@ void* vec_pop(struct Vector* vec) {
|
||||
return vec->pages[--vec->length];
|
||||
}
|
||||
|
||||
void* vec_get(struct Vector* vec, uint32_t index) {
|
||||
void* vec_get(struct Vector* vec, size_t index) {
|
||||
if (index >= vec->length)
|
||||
return NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user