sst: Quick port of recent fixes from sst branch

This commit is contained in:
Alexander Lochmann 2024-05-08 12:35:25 +02:00
parent a1c272e8b0
commit 330b4c8908

View File

@ -27,7 +27,10 @@ EXPORT_SYMBOL(get_sst_info);
static int control_thread_work(void *data) {
sst_info_t *info = (sst_info_t*)data;
int err, sleep = 0, i;
int err, i;
#if 0
int sleep = 0;
#endif
size_t len_answer = 0, len_question = 0;
char *question = NULL, *answer = NULL, *my_answer = NULL;
@ -45,10 +48,11 @@ static int control_thread_work(void *data) {
sst_debug("Received msg '%s' at 0x%lx\n", question, (uintptr_t)question);
}
len_question = strlen(question);
if (question[len_question - 1] == '?') {
if (len_question > 2 && (question[len_question - 1] == '?' ||
(question[len_question - 1] == '\n' && question[len_question - 2] == '?'))) {
my_answer = sst_answers[0];
for (i = 0; i < SST_MAX_QUESTIONS; i++) {
if (strcmp(question, sst_questions[i]) == 0) {
if (strcasecmp(question, sst_questions[i]) == 0) {
my_answer = sst_answers[i];
break;
}
@ -70,9 +74,11 @@ static int control_thread_work(void *data) {
} else {
sst_debug("The universe has an answer at 0x%lx for you!\n", (uintptr_t)answer);
}
#if 0
sleep = get_random_u8() % 90;
sst_debug("Randomly sleeping for %d secs. ZzzzZZzz\n", sleep);
ssleep(sleep);
#endif
kfree(question);
}
@ -109,7 +115,7 @@ void sst_destroy(void) {
kfree(cur_sst_info);
sst_debug("Freed private data for the universe at 0x%lx\n", (uintptr_t)cur_sst_info);
};
EXPORT_SYMBOL(sst_init);
EXPORT_SYMBOL(sst_destroy);
int sst_produce_question(sst_info_t *info, char *value) {
int err = 0;