Skip to content

Conversation

quic-bhaskarv
Copy link
Contributor

Request to merge below changes:

  • Fix compilation issues when all warnings are enabled as errors
  • Syslog based logging for the server. This will allow debugging Server issues.
  • Server configuration through config file. This allows customizing the server for Linux build flavor
  • Sample configuration file. This provides reference to configuring the server.

Copy link
Contributor

@lumag lumag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All commit messages should start with the description of an issue: 'Foo ABC is bad, change it to be BAR.'

meson.build Outdated
tqftpserv_srcs,
dependencies : [qrtr_dep, zstd_dep],
dependencies : [qrtr, zstd_dep],
c_args : ['-g', '-Wall', '-Werror', '-Wsign-compare', '-Wunused-parameter', '-Wtype-limits', '-Wimplicit-function-declaration'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obviosly an abuse of dependencies and it might break for non-gcc compilers. Please use add_global_arguments to add build options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added arguments using add_project_arguments

tqftpserv.c Outdated
}

if (tsize && *tsize != -1) {
if (tsize && *tsize != (size_t)-1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change tsize to ssize_t

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

tqftpserv.c Outdated
/* Header (4 bytes) + data size */
send_len = 4 + response_size;
if (send_len > p - buf) {
if (send_len > (size_t)(p - buf)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ptrdiff_t

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed send_len from size_t to ssize_t

*/

/* For memfd_create */
#define _GNU_SOURCE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? it was fine as is and it's not related to warnings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This macro needs to be defined for asprintf function usage in translate.c, so I moved it to meson.build

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move it back and add another one in translate.c

}

if (write(output_file_fd, decompressed_buffer, decompressed_size) != decompressed_size) {
if (write(output_file_fd, decompressed_buffer, decompressed_size) != (ssize_t)decompressed_size) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change decompressed_size to size_t or ssize_t.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

logging.c Outdated
*
* Return: Log facility constant on success, -1 on error
*/
int tqftp_parse_log_facility(const char *facility_str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use daemon, no need to let it be logged as "uucp".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* tqftp_log_init_with_config() - Initialize logging with custom configuration
* @config: Logging configuration structure
*/
void tqftp_log_init_with_config(struct tqftp_log_config *config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest using function calls instead of passing config around. I.e. set_min_level, use_console, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configuration file will allow to run the server on various linux flavors without changing the server code. I added configuration support for command line arguments as well, I will remove them and have server access paths only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? It's really easier to parse few command line options rather than having a config file parser.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add command line option, if we want to change the paths (based on the build type, android, LE, Ubuntu, etc) then we have to modify service file (or equivalent) that starts the server and this service file needs to be created based on variant.
With configuration file as well it would be similar (multiple configuration files) however, config files can be modified in on the fly for debugging. There are other tuning parameters that needs to be introduced, so I thought configuration file would be better than adding too many command line arguments.
Lets discuss which is better.

*
* Return: 0 on success, -1 on error
*/
int tqftp_config_load_file(struct tqftp_config *config, const char *filename)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes. If you want to have a config file, use one of existing libraries. I'd recommend libconfig. Or just use command line options.

Copy link
Contributor Author

@quic-bhaskarv quic-bhaskarv Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using libconfig and it is not available for all builds, does it make sense to copy libconfig in this project (I don't like this though)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't. What do you mean by it 'being not available for all builds'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'What do you mean by it 'being not available for all builds'?
I attempted to build on Android flavor and it failed, I did some experiments and understood that libconfig is present and it needed to be enabled from base config file. I have used libconfig and posted new change.

logging.h Outdated

/* Convenience macros for common logging patterns */
#define TQFTP_LOG_ERROR(fmt, ...) TQFTP_LOG_ERR(fmt, ##__VA_ARGS__)
#define TQFTP_LOG_WARN(fmt, ...) TQFTP_LOG_WARNING(fmt, ##__VA_ARGS__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need these duplicates? Select one style and use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

logging.h Outdated
#define TQFTP_LOG_PERROR(msg) TQFTP_LOG_ERR("%s: %s", msg, strerror(errno))

/* Macro to log system errors with custom format */
#define TQFTP_LOG_ERRNO(fmt, ...) TQFTP_LOG_ERR(fmt ": %s", ##__VA_ARGS__, strerror(errno))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, select one style instead of having two very similar ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

…r issues

Resolve multiple compilation issues triggered by -Wall and -Werror flags:

- Multiple warnings in in zstd_decompress_file function in zstd-decompress.h.
- Eliminate redefinition of zstd_decompress_file between zstd-decompress.h
  and zstd-decompress.c.
- Address pointer type mismatch in tqftpserv.c by correcting char * vs uint8_t *
  assignment.
- Resolve signedness comparison issues in tqftpserv.c for send_len and tsize
  checks.
- Remove unused parameters argc and argv in main() function of tqftpserv.c.

These changes ensure clean compilation and adherence to strict warning policies.

Change-Id: I1539433ec5122e0e6fc3c8e0d02900a040bc21de
Signed-off-by: Bhaskar Valaboju <[email protected]>
Introduce a project-specific logging framework through syslog.

Change-Id: Ie3399a58e9772f25979471cbf2f861ad1962d788
Signed-off-by: Bhaskar Valaboju <[email protected]>
Integrate configuration management via config file and
command-line arguments to customize server behavior.

This allows runtime configuration of key filesystem paths
including readonly_path, readwrite_path, firmware_base,
updates_dir, and temp_dir.

It also enables dynamic adjustment of the default log level,
supporting flexible deployment across platforms like Linux
and Android without requiring code changes.

Change-Id: I788ce0eb1052f43872800bc0f2e0cc5d0a6b442b
Signed-off-by: Bhaskar Valaboju <[email protected]>
Integrate syslog-based logging into tqftpserv source files.
Logging now leverages system-level facilities for consistent
output and easier debugging.

Signed-off-by: Bhaskar Valaboju <[email protected]>
Integrate configuration management via config file and
command-line arguments to customize server behavior.

This allows runtime configuration of key filesystem paths
including readonly_path, readwrite_path, firmware_base,
updates_dir, and temp_dir.

It also enables dynamic adjustment of the default log level,
supporting flexible deployment across platforms like Linux
and Android without requiring code changes.

Signed-off-by: Bhaskar Valaboju <[email protected]>
Provide a sample configuration file to support runtime
customization of server paths and log level settings.

Signed-off-by: Bhaskar Valaboju <[email protected]>
@quic-bhaskarv
Copy link
Contributor Author

quic-bhaskarv commented Aug 26, 2025

I addressed all the comments, it took time to validate on all flavors.

Integrate configuration management via config file and
command-line arguments to customize server behavior.

This allows runtime configuration of key filesystem paths
including readonly_path, readwrite_path, firmware_base,
updates_dir, and temp_dir.

It also enables dynamic adjustment of the default log level,
supporting flexible deployment across platforms like Linux
and Android without requiring code changes.

Change-Id: I788ce0eb1052f43872800bc0f2e0cc5d0a6b442b
Signed-off-by: Bhaskar Valaboju <[email protected]>
@quic-bhaskarv
Copy link
Contributor Author

Gentle Remainder!!!

@quic-bhaskarv
Copy link
Contributor Author

Gentle Remainder !!!

@quic-bhaskarv
Copy link
Contributor Author

Gentle Remainder, @lumag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants