Minor refactor.

-Rename `buffer` to `nickname`.
-In SetDeviceNickname, copy the string to a tmp stack buffer (0x80 bytes).
This commit is contained in:
The Dax 2019-06-03 21:02:09 -04:00
parent ef28afa520
commit 7854ff6921
2 changed files with 13 additions and 9 deletions

View File

@ -11,6 +11,7 @@
#include "../kernel/event.h" #include "../kernel/event.h"
#define SET_MAX_NAME_SIZE 0x48 #define SET_MAX_NAME_SIZE 0x48
#define SET_MAX_NICKNAME_SIZE 0x80
typedef enum { typedef enum {
ColorSetId_Light=0, ColorSetId_Light=0,
@ -178,12 +179,12 @@ Result setsysGetFatalDirtyFlags(u64 *flags_0, u64 *flags_1);
/** /**
* @brief Gets the system's nickname. * @brief Gets the system's nickname.
* @param buffer Pointer to output the nickname to. (The buffer size needs to be at least 0x80 bytes) * @param nickname Pointer to output the nickname to. (The buffer size needs to be at least 0x80 bytes)
*/ */
Result setsysGetDeviceNickname(char* buffer); Result setsysGetDeviceNickname(char* nickname);
/** /**
* @brief Sets the system's nickname. * @brief Sets the system's nickname.
* @param buffer Pointer to read the nickname from. * @param nickname Pointer to read the nickname from.
*/ */
Result setsysSetDeviceNickname(const char* buffer); Result setsysSetDeviceNickname(const char* nickname);

View File

@ -687,11 +687,11 @@ Result setsysGetFatalDirtyFlags(u64 *flags_0, u64 *flags_1) {
return rc; return rc;
} }
Result setsysGetDeviceNickname(char* buffer) { Result setsysGetDeviceNickname(char* nickname) {
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
ipcAddRecvBuffer(&c, buffer, 0x80, BufferType_Normal); ipcAddRecvBuffer(&c, nickname, SET_MAX_NICKNAME_SIZE, BufferType_Normal);
struct { struct {
u64 magic; u64 magic;
@ -720,11 +720,14 @@ Result setsysGetDeviceNickname(char* buffer) {
return rc; return rc;
} }
Result setsysSetDeviceNickname(const char* buffer) { Result setsysSetDeviceNickname(const char* nickname) {
char send_nickname[SET_MAX_NICKNAME_SIZE];
memset(send_nickname, 0, SET_MAX_NICKNAME_SIZE);
strncpy(send_nickname, nickname, SET_MAX_NICKNAME_SIZE-1);
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
ipcAddSendBuffer(&c, send_nickname, SET_MAX_NICKNAME_SIZE, 0);
ipcAddSendBuffer(&c, buffer, strlen(buffer) + 1, BufferType_Normal);
struct { struct {
u64 magic; u64 magic;