Skip to content

Commit

Permalink
style: removed trailing spaces and added extra CR after each doc title
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Jan 31, 2024
1 parent 9ce3c61 commit a71dd33
Show file tree
Hide file tree
Showing 52 changed files with 1,389 additions and 1,220 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Expected: February 2024

### Minor items

* Made coverity analysis and fixed most of them
* Some were ignored being for generated code (eg lex) or not applicable
* Added vcprintf

## 6.5.0
Expand Down
12 changes: 6 additions & 6 deletions cligen.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
CLIgen is a CLI generator.
CLIgen is a CLI generator.
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2001-2022 Olof Hagsand
This file is part of CLIgen.
Expand All @@ -25,7 +25,7 @@
of those above. If you wish to allow use of your version of this file only
under the terms of the GPL, and not to allow others to
use your version of this file under the terms of Apache License version 2, indicate
your decision by deleting the provisions above and replace them with the
your decision by deleting the provisions above and replace them with the
notice and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the Apache License version 2 or the GPL.
Expand All @@ -34,9 +34,9 @@
*/

/*
/*
You include cligen.h which includes the other cligen include files for you.
All cligen include files are placed in the sub-directory cligen/cligen*.h.
All cligen include files are placed in the sub-directory cligen/cligen*.h.
*/
#include <stdio.h>
#include <netinet/in.h>
Expand All @@ -54,7 +54,7 @@ typedef void *cligen_handle; /* API */
#ifdef __cplusplus
extern "C" {
#endif

#include <cligen/cligen_buf.h>
#include <cligen/cligen_cv.h>
#include <cligen/cligen_cvec.h>
Expand Down
49 changes: 30 additions & 19 deletions cligen_buf.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2001-2022 Olof Hagsand
This file is part of CLIgen.
Expand All @@ -23,14 +23,14 @@
of those above. If you wish to allow use of your version of this file only
under the terms of the GPL, and not to allow others to
use your version of this file under the terms of Apache License version 2, indicate
your decision by deleting the provisions above and replace them with the
your decision by deleting the provisions above and replace them with the
notice and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the Apache License version 2 or the GPL.
***** END LICENSE BLOCK *****
* CLIgen dynamic buffers
* CLIgen dynamic buffers
* @code
* cbuf *cb;
* if ((cb = cbuf_new()) == NULL)
Expand All @@ -46,7 +46,7 @@
* Constants
*/
/* Initial alloc mem length of a cbuf, then grows exponentially, with 2*, 4*, etc
* 1K could be a bit much for large syntaxes and small entries
* 1K could be a bit much for large syntaxes and small entries
* @see cbuf_alloc_set
*/
#define CBUFLEN_START 1024
Expand All @@ -59,13 +59,13 @@
#include <errno.h>

#include "cligen_buf.h" /* External API */
#include "cligen_buf_internal.h"
#include "cligen_buf_internal.h"

/*
* Variables
*/
/* This is how large an initial cbuf is after calling cbuf_new. Note that the cbuf
* may grow after calls to cprintf or cbuf_alloc
/* This is how large an initial cbuf is after calling cbuf_new. Note that the cbuf
* may grow after calls to cprintf or cbuf_alloc
*/
static size_t cbuflen_start = CBUFLEN_START;

Expand All @@ -75,7 +75,8 @@ static size_t cbuflen_start = CBUFLEN_START;
static size_t cbuflen_threshold = CBUFLEN_THRESHOLD;

/*! Get global cbuf initial memory allocation size
* This is how large a cbuf is after calling cbuf_new. Note that the cbuf
*
* This is how large a cbuf is after calling cbuf_new. Note that the cbuf
* may grow after calls to cprintf or cbuf_alloc
* @param[out] default Initial default cbuf size
* @param[out] threshold Threshold where cbuf grows linearly instead of exponentially
Expand All @@ -90,7 +91,8 @@ cbuf_alloc_get(size_t *start,
}

/*! Set global cbuf initial memory allocation size
* This is how large a cbuf is after calling cbuf_new. Note that the cbuf
*
* This is how large a cbuf is after calling cbuf_new. Note that the cbuf
* may grow after calls to cprintf or cbuf_alloc
* If 0 continue with exponential growth
*/
Expand All @@ -104,6 +106,7 @@ cbuf_alloc_set(size_t start,
}

/*! Allocate cligen buffer. Returned handle can be used in sprintf calls
*
* which dynamically print a string.
* The handle should be freed by cbuf_free()
* @param[in] How much buffer space for initial allocation
Expand All @@ -130,6 +133,7 @@ cbuf_new_alloc(size_t sz)
}

/*! Allocate cligen buffer with auto buffer allocation. Returned handle can be used in sprintf calls
*
* which dynamically print a string.
* The handle should be freed by cbuf_free()
* @retval cb The allocated objecyt handle on success.
Expand All @@ -143,6 +147,7 @@ cbuf_new(void)
}

/*! Free cligen buffer previously allocated with cbuf_new
*
* @param[in] cb Cligen buffer
*/
void
Expand All @@ -156,6 +161,7 @@ cbuf_free(cbuf *cb)
}

/*! Return actual byte buffer of cligen buffer
*
* @param[in] cb Cligen buffer
*/
char*
Expand All @@ -165,6 +171,7 @@ cbuf_get(cbuf *cb)
}

/*! Return length of string in cligen buffer (not buffer length itself)
*
* @param[in] cb Cligen buffer
* @see cbuf_buflen
*/
Expand All @@ -175,6 +182,7 @@ cbuf_len(cbuf *cb)
}

/*! Return length of buffer itself, ie allocated bytes
*
* @param[in] cb Cligen buffer
* @see cbuf_len
*/
Expand All @@ -185,16 +193,18 @@ cbuf_buflen(cbuf *cb)
}

/*! Reset a cligen buffer. That is, restart it from scratch.
*
* @param[in] cb Cligen buffer
*/
void
cbuf_reset(cbuf *cb)
{
cb->cb_strlen = 0;
cb->cb_buffer[0] = '\0';
cb->cb_strlen = 0;
cb->cb_buffer[0] = '\0';
}

/*! Internal buffer reallocator, Ensure buffer is large enough
*
* use quadratic expansion (2* size)
* @param[in] cb CLIgen buffer
* @param[in] len Extra length added
Expand All @@ -205,7 +215,7 @@ cbuf_realloc(cbuf *cb,
{
int retval = -1;
int diff;

diff = cb->cb_buflen - (cb->cb_strlen + sz + 1);
if (diff <= 0){
while (diff <= 0){
Expand All @@ -224,15 +234,15 @@ cbuf_realloc(cbuf *cb,
}

/*! Append a cligen buf by printf like semantics
*
*
* @param [in] cb cligen buffer allocated by cbuf_new(), may be reallocated.
* @param [in] format arguments uses printf syntax.
* @retval See printf
* @see cbuf_append_str for the optimized special case of string append
* @note cprintf assume null-terminated string as %s, use cbuf_memcp for a raw interface
*/
int
cprintf(cbuf *cb,
cprintf(cbuf *cb,
const char *format, ...)
{
int retval = -1;
Expand Down Expand Up @@ -271,7 +281,7 @@ vcprintf(cbuf *cb,
int len;
int ret;
va_list ap1;

va_copy(ap1, ap);
if (cb == NULL)
goto ok;
Expand Down Expand Up @@ -373,10 +383,11 @@ cbuf_append_buf(cbuf *cb,
}

/*! Truncate cligen buf to a shorther length
* @param [in] cb cligen buffer allocated by cbuf_new(), may be reallocated.
* @param [in] i Truncate string to this length
* @retval 0 OK
* @retval -1 Error
*
* @param [in] cb cligen buffer allocated by cbuf_new(), may be reallocated.
* @param [in] i Truncate string to this length
* @retval 0 OK
* @retval -1 Error
*/
int
cbuf_trunc(cbuf *cb,
Expand Down
8 changes: 4 additions & 4 deletions cligen_buf.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2001-2022 Olof Hagsand
This file is part of CLIgen.
Expand All @@ -23,7 +23,7 @@
of those above. If you wish to allow use of your version of this file only
under the terms of the GPL, and not to allow others to
use your version of this file under the terms of Apache License version 2, indicate
your decision by deleting the provisions above and replace them with the
your decision by deleting the provisions above and replace them with the
notice and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the Apache License version 2 or the GPL.
Expand All @@ -32,7 +32,7 @@
*
*
* CLIgen dynamic buffers
* CLIgen dynamic buffers
* @code
* cbuf *cb;
* if ((cb = cbuf_new()) == NULL)
Expand All @@ -47,7 +47,7 @@
#ifndef _CLIGEN_BUF_H
#define _CLIGEN_BUF_H

#include <stdarg.h>
#include <stdarg.h>

/*
* Types
Expand Down
10 changes: 5 additions & 5 deletions cligen_buf_internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2001-2022 Olof Hagsand
This file is part of CLIgen.
Expand All @@ -23,15 +23,15 @@
of those above. If you wish to allow use of your version of this file only
under the terms of the GPL, and not to allow others to
use your version of this file under the terms of Apache License version 2, indicate
your decision by deleting the provisions above and replace them with the
your decision by deleting the provisions above and replace them with the
notice and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the Apache License version 2 or the GPL.
***** END LICENSE BLOCK *****
*
* This is an internal CLIgen header file
* Do not use these struct for external use, the internal structure may change.
* This is an internal CLIgen header file
* Do not use these struct for external use, the internal structure may change.
* @see cligen_buf.h for external API use
*/

Expand All @@ -41,7 +41,7 @@
/*
* Types
*/
/*! Internal CLIgen buffer.
/*! Internal CLIgen buffer.
*/
struct cbuf {
char *cb_buffer; /* pointer to buffer */
Expand Down
16 changes: 8 additions & 8 deletions cligen_callback.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2001-2022 Olof Hagsand
This file is part of CLIgen.
Expand All @@ -23,7 +23,7 @@
of those above. If you wish to allow use of your version of this file only
under the terms of the GPL, and not to allow others to
use your version of this file under the terms of Apache License version 2, indicate
your decision by deleting the provisions above and replace them with the
your decision by deleting the provisions above and replace them with the
notice and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the Apache License version 2 or the GPL.
Expand Down Expand Up @@ -66,7 +66,7 @@ co_callback_next(cg_callback *cc)

/*! Copy a linked list of cg_obj callback objects
*
* Copy a linked list of cg_obj callback objects, including function pointer,
* Copy a linked list of cg_obj callback objects, including function pointer,
* function name,
*
* @param[in] cc0 The object to copy from
Expand All @@ -75,7 +75,7 @@ co_callback_next(cg_callback *cc)
* @retval -1 Error
*/
int
co_callback_copy(cg_callback *cc0,
co_callback_copy(cg_callback *cc0,
cg_callback **ccn)
{
int retval = -1;
Expand Down Expand Up @@ -113,9 +113,9 @@ co_callback_copy(cg_callback *cc0,
static int
co_callback_one_free(cg_callback *cc)
{
if (cc->cc_cvec)
if (cc->cc_cvec)
cvec_free(cc->cc_cvec);
if (cc->cc_fn_str)
if (cc->cc_fn_str)
free(cc->cc_fn_str);
free(cc);
return 0;
Expand All @@ -129,7 +129,7 @@ int
co_callbacks_free(cg_callback **ccp)
{
cg_callback *cc;

while ((cc = *ccp) != NULL){
*ccp = co_callback_next(cc);
co_callback_one_free(cc);
Expand All @@ -145,7 +145,7 @@ co_callback2cbuf(cbuf *cb,
{
int i;
cg_var *cv;

if (cc->cc_fn_str){
cprintf(cb, ", %s(", cc->cc_fn_str);
if (cc->cc_cvec){
Expand Down
4 changes: 2 additions & 2 deletions cligen_callback.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright (C) 2001-2022 Olof Hagsand
This file is part of CLIgen.
Expand All @@ -23,7 +23,7 @@
of those above. If you wish to allow use of your version of this file only
under the terms of the GPL, and not to allow others to
use your version of this file under the terms of Apache License version 2, indicate
your decision by deleting the provisions above and replace them with the
your decision by deleting the provisions above and replace them with the
notice and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the Apache License version 2 or the GPL.
Expand Down
Loading

0 comments on commit a71dd33

Please sign in to comment.