string: Reformat

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2025-04-24 16:20:57 +02:00
committed by Andreas Schneider
parent 6fc1bf6901
commit 5d27f69494

View File

@@ -84,9 +84,10 @@ struct ssh_string_struct *ssh_string_new(size_t size)
*
* @return 0 on success, < 0 on error.
*/
int ssh_string_fill(struct ssh_string_struct *s, const void *data, size_t len) {
if ((s == NULL) || (data == NULL) ||
(len == 0) || (len > ssh_string_len(s))) {
int ssh_string_fill(struct ssh_string_struct *s, const void *data, size_t len)
{
if ((s == NULL) || (data == NULL) || (len == 0) ||
(len > ssh_string_len(s))) {
return -1;
}
@@ -105,11 +106,12 @@ int ssh_string_fill(struct ssh_string_struct *s, const void *data, size_t len) {
*
* @note The null byte is not copied nor counted in the output string.
*/
struct ssh_string_struct *ssh_string_from_char(const char *what) {
struct ssh_string_struct *ssh_string_from_char(const char *what)
{
struct ssh_string_struct *ptr;
size_t len;
if(what == NULL) {
if (what == NULL) {
errno = EINVAL;
return NULL;
}
@@ -133,7 +135,8 @@ struct ssh_string_struct *ssh_string_from_char(const char *what) {
*
* @return The size of the content of the string, 0 on error.
*/
size_t ssh_string_len(struct ssh_string_struct *s) {
size_t ssh_string_len(struct ssh_string_struct *s)
{
size_t size;
if (s == NULL) {
@@ -164,7 +167,7 @@ const char *ssh_string_get_char(struct ssh_string_struct *s)
}
s->data[ssh_string_len(s)] = '\0';
return (const char *) s->data;
return (const char *)s->data;
}
/**
@@ -178,7 +181,8 @@ const char *ssh_string_get_char(struct ssh_string_struct *s)
* @note If the input SSH string contains zeroes, some parts of the output
* string may not be readable with regular libc functions.
*/
char *ssh_string_to_char(struct ssh_string_struct *s) {
char *ssh_string_to_char(struct ssh_string_struct *s)
{
size_t len;
char *new;
@@ -206,7 +210,8 @@ char *ssh_string_to_char(struct ssh_string_struct *s) {
*
* @param[in] s The string to delete.
*/
void ssh_string_free_char(char *s) {
void ssh_string_free_char(char *s)
{
SAFE_FREE(s);
}
@@ -218,7 +223,8 @@ void ssh_string_free_char(char *s) {
*
* @return Newly allocated copy of the string, NULL on error.
*/
struct ssh_string_struct *ssh_string_copy(struct ssh_string_struct *s) {
struct ssh_string_struct *ssh_string_copy(struct ssh_string_struct *s)
{
struct ssh_string_struct *new;
size_t len;
@@ -246,7 +252,8 @@ struct ssh_string_struct *ssh_string_copy(struct ssh_string_struct *s) {
*
* @param[in] s The string to burn.
*/
void ssh_string_burn(struct ssh_string_struct *s) {
void ssh_string_burn(struct ssh_string_struct *s)
{
if (s == NULL || s->size == 0) {
return;
}
@@ -261,7 +268,8 @@ void ssh_string_burn(struct ssh_string_struct *s) {
*
* @return Return the data of the string or NULL on error.
*/
void *ssh_string_data(struct ssh_string_struct *s) {
void *ssh_string_data(struct ssh_string_struct *s)
{
if (s == NULL) {
return NULL;
}
@@ -274,7 +282,8 @@ void *ssh_string_data(struct ssh_string_struct *s) {
*
* \param[in] s The SSH string to delete.
*/
void ssh_string_free(struct ssh_string_struct *s) {
void ssh_string_free(struct ssh_string_struct *s)
{
SAFE_FREE(s);
}