mirror of
https://github.com/linux-msm/qdl.git
synced 2026-02-25 13:12:25 -08:00
Merge pull request #116 from igoropaniuk/checkpatch_rework
Checkpatch exceptions and rework
This commit is contained in:
@@ -1,5 +1,35 @@
|
||||
--no-tree
|
||||
--strict
|
||||
--max-line-length=120
|
||||
--ignore FILE_PATH_CHANGES
|
||||
--ignore EMAIL_SUBJECT
|
||||
--ignore SPLIT_STRING
|
||||
|
||||
# NEW_TYPEDEFS reports "do not add new typedefs"
|
||||
# typedef struct __attribute__((__packed__)) sparse_header {
|
||||
--ignore NEW_TYPEDEFS
|
||||
|
||||
# PREFER_DEFINED_ATTRIBUTE_MACRO reports this kind of messages:
|
||||
# WARNING: Prefer __packed over __attribute__((__packed__))
|
||||
--ignore PREFER_DEFINED_ATTRIBUTE_MACRO
|
||||
|
||||
# PREFER_KERNEL_TYPES reports this kind of messages (when using --strict):
|
||||
# "Prefer kernel type 'u32' over 'uint32_t'"
|
||||
--ignore PREFER_KERNEL_TYPES
|
||||
|
||||
# BRACES reports this kind of messages:
|
||||
# braces {} are not necessary for any arm of this statement
|
||||
--ignore BRACES
|
||||
|
||||
# CAMELCASE reports this kind of messages:
|
||||
# Avoid CamelCase: <xmlFreeDoc>
|
||||
--ignore CAMELCASE
|
||||
|
||||
# AVOID_EXTERNS reports this kind of messages:
|
||||
# externs should be avoided in .c files
|
||||
# extern const char *__progname;
|
||||
--ignore AVOID_EXTERNS
|
||||
|
||||
# COMMIT_LOG_LONG_LINE reports line lengths > 75 in commit log
|
||||
# Lets ignore this
|
||||
--ignore COMMIT_LOG_LONG_LINE
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,3 +7,5 @@ compile_commands.json
|
||||
.cache
|
||||
.version.h
|
||||
version.h
|
||||
scripts
|
||||
.checkpatch-camelcase.git.
|
||||
|
||||
32
Makefile
32
Makefile
@@ -16,6 +16,13 @@ KS_OUT := ks
|
||||
KS_SRCS := ks.c sahara.c util.c ux.c oscompat.c
|
||||
KS_OBJS := $(KS_SRCS:.c=.o)
|
||||
|
||||
CHECKPATCH_SOURCES := $(shell find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.sh" \) ! -name "sha2.c" ! -name "sha2.h" ! -name "*version.h")
|
||||
CHECKPATCH_ROOT := https://raw.githubusercontent.com/torvalds/linux/v6.15/scripts
|
||||
CHECKPATCH_URL := $(CHECKPATCH_ROOT)/checkpatch.pl
|
||||
CHECKPATCH_SP_URL := $(CHECKPATCH_ROOT)/spelling.txt
|
||||
CHECKPATCH := ./.scripts/checkpatch.pl
|
||||
CHECKPATCH_SP := ./.scripts/spelling.txt
|
||||
|
||||
default: $(QDL) $(RAMDUMP) $(KS_OUT)
|
||||
|
||||
$(QDL): $(QDL_OBJS)
|
||||
@@ -42,6 +49,9 @@ clean:
|
||||
rm -f $(KS_OUT) $(KS_OBJS)
|
||||
rm -f compile_commands.json
|
||||
rm -f version.h .version.h
|
||||
rm -f $(CHECKPATCH)
|
||||
rm -f $(CHECKPATCH_SP)
|
||||
if [ -d .scripts ]; then rmdir .scripts; fi
|
||||
|
||||
install: $(QDL) $(RAMDUMP) $(KS_OUT)
|
||||
install -d $(DESTDIR)$(prefix)/bin
|
||||
@@ -50,3 +60,25 @@ install: $(QDL) $(RAMDUMP) $(KS_OUT)
|
||||
tests: default
|
||||
tests:
|
||||
@./tests/run_tests.sh
|
||||
|
||||
# Target to download checkpatch.pl if not present
|
||||
$(CHECKPATCH):
|
||||
@echo "Downloading checkpatch.pl..."
|
||||
@mkdir -p $(dir $(CHECKPATCH))
|
||||
@curl -sSfL $(CHECKPATCH_URL) -o $(CHECKPATCH)
|
||||
@curl -sSfL $(CHECKPATCH_SP_URL) -o $(CHECKPATCH_SP)
|
||||
@chmod +x $(CHECKPATCH)
|
||||
|
||||
check: $(CHECKPATCH)
|
||||
@echo "Running checkpatch on source files (excluding sha2.c and sha2.h)..."
|
||||
@for file in $(CHECKPATCH_SOURCES); do \
|
||||
perl $(CHECKPATCH) --no-tree -f $$file || exit 1; \
|
||||
done
|
||||
|
||||
check-cached: $(CHECKPATCH)
|
||||
@echo "Running checkpatch on staged changes..."
|
||||
@git diff --cached --name-only --diff-filter=ACMRT | grep -E '\.(c|h)$$' | while read file; do \
|
||||
if [ -f "$$file" ]; then \
|
||||
git show :$$file | perl $(CHECKPATCH) --no-tree -; \
|
||||
fi \
|
||||
done
|
||||
|
||||
@@ -681,7 +681,8 @@ int firehose_apply_ufs_common(struct qdl_device *qdl, struct ufs_common *ufs)
|
||||
xml_setpropf(node_to_send, "bConfigDescrLock", "%d", ufs->bConfigDescrLock);
|
||||
|
||||
if (ufs->wb) {
|
||||
xml_setpropf(node_to_send, "bWriteBoosterBufferPreserveUserSpaceEn", "%d", ufs->bWriteBoosterBufferPreserveUserSpaceEn);
|
||||
xml_setpropf(node_to_send, "bWriteBoosterBufferPreserveUserSpaceEn",
|
||||
"%d", ufs->bWriteBoosterBufferPreserveUserSpaceEn);
|
||||
xml_setpropf(node_to_send, "bWriteBoosterBufferType", "%d", ufs->bWriteBoosterBufferType);
|
||||
xml_setpropf(node_to_send, "shared_wb_buffer_size_in_kb", "%d", ufs->shared_wb_buffer_size_in_kb);
|
||||
}
|
||||
|
||||
1
ks.c
1
ks.c
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
#ifndef __OSCOMPAT_H__
|
||||
#define __OSCOMPAT_H__
|
||||
|
||||
|
||||
1
patch.h
1
patch.h
@@ -1,3 +1,4 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
#ifndef __PATCH_H__
|
||||
#define __PATCH_H__
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ static int load_program_tag(xmlNode *node, bool is_nand)
|
||||
|
||||
if (is_nand) {
|
||||
program->pages_per_block = attr_as_unsigned(node, "PAGES_PER_BLOCK", &errors);
|
||||
if (NULL != xmlGetProp(node, (xmlChar *)"last_sector")) {
|
||||
if (xmlGetProp(node, (xmlChar *)"last_sector")) {
|
||||
program->last_sector = attr_as_unsigned(node, "last_sector", &errors);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
#ifndef __PROGRAM_H__
|
||||
#define __PROGRAM_H__
|
||||
|
||||
|
||||
18
qdl.h
18
qdl.h
@@ -1,3 +1,4 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
#ifndef __QDL_H__
|
||||
#define __QDL_H__
|
||||
|
||||
@@ -11,13 +12,22 @@
|
||||
|
||||
#define container_of(ptr, typecast, member) ({ \
|
||||
void *_ptr = (void *)(ptr); \
|
||||
((typecast *)(_ptr - offsetof(typecast, member))); })
|
||||
((typeof(typecast) *)(_ptr - offsetof(typecast, member))); })
|
||||
|
||||
#define MIN(x, y) ({ \
|
||||
__typeof__(x) _x = (x); \
|
||||
__typeof__(y) _y = (y); \
|
||||
_x < _y ? _x : _y; \
|
||||
})
|
||||
|
||||
#define ROUND_UP(x, a) ({ \
|
||||
__typeof__(x) _x = (x); \
|
||||
__typeof__(a) _a = (a); \
|
||||
(_x + _a - 1) & ~(_a - 1); \
|
||||
})
|
||||
|
||||
#define MAPPING_SZ 64
|
||||
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
|
||||
|
||||
enum QDL_DEVICE_TYPE {
|
||||
QDL_DEVICE_USB,
|
||||
QDL_DEVICE_SIM,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
#include <getopt.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
1
read.h
1
read.h
@@ -1,3 +1,4 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
#ifndef __READ_H__
|
||||
#define __READ_H__
|
||||
|
||||
|
||||
8
sahara.c
8
sahara.c
@@ -19,8 +19,6 @@
|
||||
#include "qdl.h"
|
||||
#include "oscompat.h"
|
||||
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
#define SAHARA_HELLO_CMD 0x1 /* Min protocol version 1.0 */
|
||||
#define SAHARA_HELLO_RESP_CMD 0x2 /* Min protocol version 1.0 */
|
||||
#define SAHARA_READ_DATA_CMD 0x3 /* Min protocol version 1.0 */
|
||||
@@ -420,8 +418,10 @@ static void sahara_debug64(struct qdl_device *qdl, struct sahara_pkt *pkt,
|
||||
if (sahara_debug64_filter(table[i].filename, filter))
|
||||
continue;
|
||||
|
||||
ux_debug("%-2d: type 0x%" PRIx64 " address: 0x%" PRIx64 " length: 0x%" PRIx64 " region: %s filename: %s\n",
|
||||
i, table[i].type, table[i].addr, table[i].length, table[i].region, table[i].filename);
|
||||
ux_debug("%-2d: type 0x%" PRIx64 " address: 0x%" PRIx64 " length: 0x%"
|
||||
PRIx64 " region: %s filename: %s\n",
|
||||
i, table[i].type, table[i].addr, table[i].length,
|
||||
table[i].region, table[i].filename);
|
||||
|
||||
n = sahara_debug64_one(qdl, table[i], ramdump_path);
|
||||
if (n < 0)
|
||||
|
||||
10
sim.c
10
sim.c
@@ -20,10 +20,7 @@ static int sim_open(struct qdl_device *qdl, const char *serial)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sim_close(struct qdl_device *qdl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void sim_close(struct qdl_device *qdl) {}
|
||||
|
||||
static int sim_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout)
|
||||
{
|
||||
@@ -35,10 +32,7 @@ static int sim_write(struct qdl_device *qdl, const void *buf, size_t len)
|
||||
return len;
|
||||
}
|
||||
|
||||
static void sim_set_out_chunk_size(struct qdl_device *qdl, long size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static void sim_set_out_chunk_size(struct qdl_device *qdl, long size) {}
|
||||
|
||||
struct qdl_device *sim_init(void)
|
||||
{
|
||||
|
||||
5
ufs.c
5
ufs.c
@@ -31,7 +31,6 @@ static const char notice_bconfigdescrlock[] = "\n"
|
||||
" and don't use command line parameter --finalize-provisioning.\n\n"
|
||||
"In case of mismatch between CL and XML provisioning is not performed.\n\n";
|
||||
|
||||
|
||||
bool ufs_need_provisioning(void)
|
||||
{
|
||||
return !!ufs_epilogue_p;
|
||||
@@ -63,7 +62,9 @@ struct ufs_common *ufs_parse_common_params(xmlNode *node, bool finalize_provisio
|
||||
|
||||
/* These parameters are optional */
|
||||
errors = 0;
|
||||
result->bWriteBoosterBufferPreserveUserSpaceEn = !!attr_as_unsigned(node, "bWriteBoosterBufferPreserveUserSpaceEn", &errors);
|
||||
result->bWriteBoosterBufferPreserveUserSpaceEn = !!attr_as_unsigned(node,
|
||||
"bWriteBoosterBufferPreserveUserSpaceEn",
|
||||
&errors);
|
||||
result->bWriteBoosterBufferType = !!attr_as_unsigned(node, "bWriteBoosterBufferType", &errors);
|
||||
result->shared_wb_buffer_size_in_kb = attr_as_unsigned(node, "shared_wb_buffer_size_in_kb", &errors);
|
||||
result->wb = !errors;
|
||||
|
||||
6
ufs.h
6
ufs.h
@@ -47,9 +47,9 @@ struct ufs_epilogue {
|
||||
|
||||
int ufs_load(const char *ufs_file, bool finalize_provisioning);
|
||||
int ufs_provisioning_execute(struct qdl_device *qdl,
|
||||
int (*apply_ufs_common)(struct qdl_device *qdl, struct ufs_common *ufs),
|
||||
int (*apply_ufs_body)(struct qdl_device *qdl, struct ufs_body *ufs),
|
||||
int (*apply_ufs_epilogue)(struct qdl_device *qdl, struct ufs_epilogue *ufs, bool commit));
|
||||
int (*apply_ufs_common)(struct qdl_device *qdl, struct ufs_common *ufs),
|
||||
int (*apply_ufs_body)(struct qdl_device *qdl, struct ufs_body *ufs),
|
||||
int (*apply_ufs_epilogue)(struct qdl_device *qdl, struct ufs_epilogue *ufs, bool commit));
|
||||
bool ufs_need_provisioning(void);
|
||||
|
||||
#endif
|
||||
|
||||
1
usb.c
1
usb.c
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
3
util.c
3
util.c
@@ -11,10 +11,9 @@
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
#include "qdl.h"
|
||||
#include "version.h"
|
||||
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
static uint8_t to_hex(uint8_t ch)
|
||||
{
|
||||
ch &= 0xf;
|
||||
|
||||
26
ux.c
26
ux.c
@@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
#include <stdarg.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@@ -9,13 +10,14 @@
|
||||
|
||||
#include "qdl.h"
|
||||
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
#define UX_PROGRESS_REFRESH_RATE 10
|
||||
#define UX_PROGRESS_SIZE_MAX 120
|
||||
#define UX_PROGRESS_SIZE_MAX 80
|
||||
|
||||
static const char * const progress_hashes = "########################################################################################################################";
|
||||
static const char * const progress_dashes = "------------------------------------------------------------------------------------------------------------------------";
|
||||
#define HASHES "################################################################################"
|
||||
#define DASHES "--------------------------------------------------------------------------------"
|
||||
|
||||
static const char * const progress_hashes = HASHES;
|
||||
static const char * const progress_dashes = DASHES;
|
||||
|
||||
static unsigned int ux_width;
|
||||
static unsigned int ux_cur_line_length;
|
||||
@@ -44,15 +46,15 @@ static void ux_clear_line(void)
|
||||
|
||||
void ux_init(void)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
int columns;
|
||||
|
||||
HANDLE stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
HANDLE stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
if (GetConsoleScreenBufferInfo(stdoutHandle, &csbi)) {
|
||||
if (GetConsoleScreenBufferInfo(stdoutHandle, &csbi)) {
|
||||
columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
|
||||
ux_width = MIN(columns, UX_PROGRESS_SIZE_MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -160,9 +162,9 @@ void ux_progress(const char *fmt, unsigned int value, unsigned int max, ...)
|
||||
|
||||
printf("%-20.20s [%.*s%.*s] %1.2f%%%n\r", task_name,
|
||||
bars, progress_hashes,
|
||||
dashes, progress_dashes,
|
||||
percent * 100,
|
||||
&ux_cur_line_length);
|
||||
dashes, progress_dashes,
|
||||
percent * 100,
|
||||
&ux_cur_line_length);
|
||||
fflush(stdout);
|
||||
|
||||
gettimeofday(&last_progress_update, NULL);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user