Skip to content

Commit

Permalink
Clean up Jansson source tree, document changes made
Browse files Browse the repository at this point in the history
* Update jansson_private_config.h to accurately reflect the presence or
  absence of certain compiler features and headers
* Mark one function as unused to prevent a compilation warning
* Disable one warning on GCC
* Validate that all imported C files are used in the build
* Remove unused Jansson build files, preserve LICENSE
* Document these changes in WEBDIS-CHANGES.md and link from README.md
  • Loading branch information
nicolasff committed Oct 5, 2024
1 parent 8a86600 commit 2cc9ca5
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 291 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

# About Webdis

A very simple web server providing an HTTP interface to Redis. It uses [hiredis](https://github.com/antirez/hiredis), [jansson](https://github.com/akheron/jansson), [libevent](https://monkey.org/~provos/libevent/), and [http-parser](https://github.com/ry/http-parser/).
A very simple web server providing an HTTP interface to Redis. It embeds [hiredis](https://github.com/antirez/hiredis), [jansson](https://github.com/akheron/jansson) (with some [local changes](./src/jansson/WEBDIS-CHANGES.md)), and [http-parser](https://github.com/ry/http-parser/). It also depends on [libevent](https://monkey.org/~provos/libevent/), to be installed separately.

Webdis depends on libevent-dev. You can install it on Ubuntu by typing `sudo apt-get install libevent-dev` or on macOS by typing `brew install libevent`.
# Build and run from source

To build Webdis with support for encrypted connections to Redis, see [Building Webdis with SSL support](#building-webdis-with-ssl-support).
Building Webdis requires the libevent development package. You can install it on Ubuntu by typing `sudo apt-get install libevent-dev` or on macOS by typing `brew install libevent`.

# Build and run from source
To build Webdis with support for encrypted connections to Redis, see [Building Webdis with SSL support](#building-webdis-with-ssl-support).

```sh
$ make clean all
Expand Down
12 changes: 0 additions & 12 deletions src/jansson/Makefile.am

This file was deleted.

37 changes: 37 additions & 0 deletions src/jansson/WEBDIS-CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Webdis changes to Jansson

Webdis imports Jansson by including its source code under `src/jansson`. This document lists the changes made to Jansson files, mostly made to accommodate the requirements of the Webdis build process.

Webdis currently imports Jansson version 2.14.

## Includes and compiler builtins

Added checks for various headers and compiler builtins. For example, `endian.h` is not available on macOS, although `machine/endian.h` is.

## Unused code

Marked `buf_to_uint32` as unused.

## Unused source files

To validate that all the C files imported are used in the build, we can compare the list of files in the Jansson source directory with the object files listed in the Webdis Makefile.

The following `diff` command should not show any output:

```sh
diff -u <(grep ^JANSSON_OBJ Makefile | head -1 | cut -f 2- -d = | tr ' ' '\n' | sed -Ee 's/\.o$/.c/g' | sort)\
<(find src/jansson/src -name '*.c' | sort)
```

## Unused build files

Autotool build files can be removed, namely:
- `configure.ac`
- `jansson.pc.in`
- `Makefile.am` (2 copies)
- `jansson_config.h.in`

## Disabled warning

A `#pragma` is used in `src/jansson/src/load.c` to disable overly strict warnings about string truncation.
No overflow is possible, GCC is only warning about the possibility of a string being truncated if it doesn't fit in the destination buffer.
181 changes: 0 additions & 181 deletions src/jansson/configure.ac

This file was deleted.

10 changes: 0 additions & 10 deletions src/jansson/jansson.pc.in

This file was deleted.

30 changes: 0 additions & 30 deletions src/jansson/src/Makefile.am

This file was deleted.

1 change: 1 addition & 0 deletions src/jansson/src/hashtable_seed.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include "jansson.h"

__attribute__ ((unused))
static uint32_t buf_to_uint32(char *data) {
size_t i;
uint32_t result = 0;
Expand Down
51 changes: 0 additions & 51 deletions src/jansson/src/jansson_config.h.in

This file was deleted.

23 changes: 21 additions & 2 deletions src/jansson/src/jansson_private_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,31 @@
/* jansson_private_config.h.in. Generated from configure.ac by autoheader. */

/* Define to 1 if gcc's __atomic builtins are available */
#define HAVE_ATOMIC_BUILTINS 1
#if defined(__has_include) && __has_include(<stdatomic.h>)
# include <stdatomic.h>
# define HAVE_ATOMIC_BUILTINS 1
#else
# define HAVE_ATOMIC_BUILTINS 0
#endif

/* Define to 1 if you have the `close' function. */
#define HAVE_CLOSE 1

/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the <endian.h> header file. */
/* Locate the <endian.h> header file. */
#if defined(__has_include) && __has_include(<endian.h>)
#define HAVE_ENDIAN_H 1
#else
#define HAVE_ENDIAN_H 0
#endif
#if defined(__has_include) && __has_include(<machine/endian.h>)
#define HAVE_MACHINE_ENDIAN_H 1
#else
#define HAVE_MACHINE_ENDIAN_H 0
#endif


/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
Expand Down Expand Up @@ -65,7 +80,11 @@
#define HAVE_STRTOLL 1

/* Define to 1 if gcc's __sync builtins are available */
#ifdef __GNUC__
#define HAVE_SYNC_BUILTINS 1
#else
#define HAVE_SYNC_BUILTINS 0
#endif

/* Define to 1 if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
Expand Down
Loading

0 comments on commit 2cc9ca5

Please sign in to comment.