Skip to content

Commit 3a87735

Browse files
committed
dtrace: de-typedef.
Done largely via new scripts in scripts/coccinelle/dtrace, one to remove struct typedefs, the other to remove enum typedefs. (Manual adjustments atop this: consistently reflow all structure-returning function definitions to put the return type on the previous line, repair tabbing of declarators, and general adjustments to fit within 80 chars.) Run via spatch --cocci-file scripts/coccinelle/dtrace/typedef-elision.cocci \ --defined 'IS_ENABLED(CONFIG_DT_FASTTRAP)' --prevent-kr \ --patch . -I ./arch/x86/include -I ./arch/x86/include/asm \ -I ./arch/x86/include/generated -I ./include \ -I ./arch/x86/include/uapi -I ./arch/x86/include/generated/uapi -I ./include/uapi -I ./include/generated/uapi \ --include ./include/linux/kconfig.h include/linux/dtrace*.h \ include/dtrace/*.h include/uapi/linux/dtrace/*.h dtrace/*.h \ dtrace/*.c kernel/dtrace/*.c arch/x86_64/dtrace/*.c \ arch/x86_64/kernel/dtrace*c kernel/sched/sched.h aarch64 gets something similar, run over an untouched tree with s/x86_64/aarch64/ and the resulting patch edited to remove non-arm content: we have to rerun it over the headers because that's where most of the typedefs are picked up from. Edited post facto to ensure that typedefs remain in the uapi headers and that all our tab-aligned declarationn blocks either still align or are no longer tab-aligned at all (Coccinelle de-tabbed some completely and I can't say it looks worse). Fixing up the tabs took longer than everything else, including learning how to use Coccinelle in the first place. Those tabs really should go. Signed-off-by: Nick Alcock <[email protected]>
1 parent b5c5d86 commit 3a87735

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1788
-1572
lines changed

arch/arm64/dtrace/dtrace_isa_arm64.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ ulong_t dtrace_getreg(struct task_struct *task, uint_t reg)
142142
return regs_get_register(rp, reg * sizeof(uint64_t));
143143
}
144144

145-
void pdata_init(dtrace_module_t *pdata, struct module *mp)
145+
void pdata_init(struct dtrace_module *pdata, struct module *mp)
146146
{
147147
/*
148148
* Throw away existing data as we don't support reusal at
@@ -155,7 +155,7 @@ void pdata_init(dtrace_module_t *pdata, struct module *mp)
155155
pdata->fbt_tab = NULL;
156156
}
157157

158-
void pdata_cleanup(dtrace_module_t *pdata, struct module *mp)
158+
void pdata_cleanup(struct dtrace_module *pdata, struct module *mp)
159159
{
160160
if (pdata->sdt_tab != NULL)
161161
dtrace_free_text(pdata->sdt_tab);

arch/arm64/dtrace/fasttrap_arm64.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ static uint64_t *fasttrap_all_offsets(asm_instr_t *text, size_t size,
100100
return NULL;
101101
}
102102

103-
uint64_t *fasttrap_glob_offsets(fasttrap_probe_spec_t *probe, uint64_t *np)
103+
uint64_t *fasttrap_glob_offsets(struct fasttrap_probe_spec *probe,
104+
uint64_t *np)
104105
{
105106
size_t size = probe->ftps_size;
106107
asm_instr_t *text = NULL;
@@ -224,8 +225,8 @@ uint64_t fasttrap_usdt_getarg(void *arg, dtrace_id_t id, void *parg,
224225
return fasttrap_pid_getarg(arg, id, parg, argno, aframes);
225226
}
226227

227-
static void fasttrap_map_args(fasttrap_probe_t *probe, struct pt_regs *regs,
228-
int argc, uintptr_t *argv)
228+
static void fasttrap_map_args(struct fasttrap_probe *probe,
229+
struct pt_regs *regs, int argc, uintptr_t *argv)
229230
{
230231
int i, x, cap = min(argc, (int)probe->ftp_nargs);
231232
uintptr_t *st = (uintptr_t *)regs->sp;
@@ -248,7 +249,7 @@ static void fasttrap_map_args(fasttrap_probe_t *probe, struct pt_regs *regs,
248249
argv[i++] = 0;
249250
}
250251

251-
void fasttrap_pid_probe_arch(fasttrap_probe_t *ftp, struct pt_regs *regs)
252+
void fasttrap_pid_probe_arch(struct fasttrap_probe *ftp, struct pt_regs *regs)
252253
{
253254
if (ftp->ftp_argmap == NULL) {
254255
dtrace_probe(ftp->ftp_id, regs->regs[0], regs->regs[1],
@@ -264,7 +265,8 @@ void fasttrap_pid_probe_arch(fasttrap_probe_t *ftp, struct pt_regs *regs)
264265
}
265266
}
266267

267-
void fasttrap_pid_retprobe_arch(fasttrap_probe_t *ftp, struct pt_regs *regs)
268+
void fasttrap_pid_retprobe_arch(struct fasttrap_probe *ftp,
269+
struct pt_regs *regs)
268270
{
269271
/*
270272
* FIXME: The first argument to the probe should be the offset in the

arch/arm64/dtrace/sdt_arm64.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
static int sdt_brk_hook(struct pt_regs *regs, unsigned int esr)
2727
{
28-
uintptr_t ip = instruction_pointer(regs);
29-
sdt_probe_t *sdt = sdt_probetab[SDT_ADDR2NDX(ip)];
28+
uintptr_t ip = instruction_pointer(regs);
29+
struct sdt_probe *sdt = sdt_probetab[SDT_ADDR2NDX(ip)];
3030

3131
for (; sdt != NULL; sdt = sdt->sdp_hashnext) {
3232
if ((uintptr_t)sdt->sdp_patchpoint == ip) {
@@ -51,7 +51,7 @@ static int sdt_brk_hook(struct pt_regs *regs, unsigned int esr)
5151
return DBG_HOOK_ERROR;
5252
}
5353

54-
void sdt_provide_probe_arch(sdt_probe_t *sdp, struct module *mp, int idx)
54+
void sdt_provide_probe_arch(struct sdt_probe *sdp, struct module *mp, int idx)
5555
{
5656
sdp->sdp_patchval = BRK64_OPCODE_DPROBE_SDT;
5757
sdp->sdp_savedval = dtrace_text_peek(sdp->sdp_patchpoint);
@@ -66,12 +66,12 @@ void sdt_destroy_module(void *arg, struct module *mp)
6666
{
6767
}
6868

69-
void sdt_enable_arch(sdt_probe_t *sdp, dtrace_id_t id, void *arg)
69+
void sdt_enable_arch(struct sdt_probe *sdp, dtrace_id_t id, void *arg)
7070
{
7171
dtrace_text_poke(sdp->sdp_patchpoint, sdp->sdp_patchval);
7272
}
7373

74-
void sdt_disable_arch(sdt_probe_t *sdp, dtrace_id_t id, void *arg)
74+
void sdt_disable_arch(struct sdt_probe *sdp, dtrace_id_t id, void *arg)
7575
{
7676
dtrace_text_poke(sdp->sdp_patchpoint, sdp->sdp_savedval);
7777
}

arch/arm64/include/asm/dtrace_arch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ typedef int (*prov_exit_f)(void);
1919
* - sdt_probec: number of SDT probes in the module
2020
* - pdata: pointer to a dtrace_module struct (for DTrace)
2121
*/
22-
typedef struct dtrace_module {
22+
struct dtrace_module {
2323
int enabled_cnt;
2424
size_t sdt_probe_cnt;
2525
asm_instr_t *sdt_tab;
2626
size_t fbt_probe_cnt;
2727
asm_instr_t *fbt_tab;
2828
prov_exit_f prov_exit; /* Called with module_mutex held */
29-
} dtrace_module_t;
29+
};
3030

3131
#endif /* _ASM_ARM64_DTRACE_ARCH_H */

arch/arm64/kernel/dtrace_fbt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void dtrace_fbt_init(fbt_add_probe_fn fbt_add_probe, struct module *mp,
4444
loff_t pos;
4545
struct kallsym_iter sym;
4646
asm_instr_t *paddr = NULL;
47-
dt_fbt_bl_entry_t *blent = NULL;
47+
struct dt_fbt_bl_entry *blent = NULL;
4848

4949
/*
5050
* Look up any unresolved symbols in the blacklist, and sort the list

arch/arm64/kernel/dtrace_syscall.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void systrace_stub(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
2121

2222
asmlinkage long systrace_syscall(const struct pt_regs *regs);
2323

24-
static systrace_info_t systrace_info = {
24+
static struct systrace_info systrace_info = {
2525
&systrace_probe,
2626
systrace_stub,
2727
systrace_syscall,
@@ -40,7 +40,7 @@ asmlinkage long systrace_syscall(const struct pt_regs *regs)
4040
long rc = 0;
4141
unsigned long sysnum;
4242
dtrace_id_t id;
43-
dtrace_syscalls_t *sc;
43+
struct dtrace_syscalls *sc;
4444

4545
sysnum = syscall_get_nr(current, (struct pt_regs *) regs);
4646
sc = &systrace_info.sysent[sysnum];
@@ -67,7 +67,8 @@ asmlinkage long systrace_syscall(const struct pt_regs *regs)
6767
return rc;
6868
}
6969

70-
systrace_info_t *dtrace_syscalls_init()
70+
struct systrace_info *
71+
dtrace_syscalls_init()
7172
{
7273
int i;
7374

arch/arm64/kernel/dtrace_util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static int dtrace_unwind_frame(struct user_stackframe *frame)
120120
return 0;
121121
}
122122

123-
void dtrace_user_stacktrace(stacktrace_state_t *st)
123+
void dtrace_user_stacktrace(struct stacktrace_state *st)
124124
{
125125
struct pt_regs *regs = current_pt_regs();
126126
uint64_t *pcs = st->pcs;
@@ -283,10 +283,10 @@ void dtrace_brk_stop(void *arg)
283283
}
284284
EXPORT_SYMBOL(dtrace_brk_stop);
285285

286-
void dtrace_mod_pdata_init(dtrace_module_t *pdata)
286+
void dtrace_mod_pdata_init(struct dtrace_module *pdata)
287287
{
288288
}
289289

290-
void dtrace_mod_pdata_cleanup(dtrace_module_t *pdata)
290+
void dtrace_mod_pdata_cleanup(struct dtrace_module *pdata)
291291
{
292292
}

arch/x86/dtrace/fasttrap_x86_64.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ static uint64_t *fasttrap_all_offsets(asm_instr_t *text, size_t size,
126126
return NULL;
127127
}
128128

129-
uint64_t *fasttrap_glob_offsets(fasttrap_probe_spec_t *probe, uint64_t *np)
129+
uint64_t *fasttrap_glob_offsets(struct fasttrap_probe_spec *probe,
130+
uint64_t *np)
130131
{
131132
size_t size = probe->ftps_size;
132133
asm_instr_t *text = NULL;
@@ -291,7 +292,8 @@ uint64_t fasttrap_usdt_getarg(void *arg, dtrace_id_t id, void *parg,
291292
return val;
292293
}
293294

294-
static void fasttrap_map_args(fasttrap_probe_t *probe, struct pt_regs *regs,
295+
static void fasttrap_map_args(struct fasttrap_probe *probe,
296+
struct pt_regs *regs,
295297
int argc, uintptr_t *argv)
296298
{
297299
int i, x, cap = min(argc, (int)probe->ftp_nargs);
@@ -330,7 +332,7 @@ static void fasttrap_map_args(fasttrap_probe_t *probe, struct pt_regs *regs,
330332
argv[i++] = 0;
331333
}
332334

333-
void fasttrap_pid_probe_arch(fasttrap_probe_t *ftp, struct pt_regs *regs)
335+
void fasttrap_pid_probe_arch(struct fasttrap_probe *ftp, struct pt_regs *regs)
334336
{
335337
if (ftp->ftp_argmap == NULL) {
336338
dtrace_probe(ftp->ftp_id, regs->di, regs->si, regs->dx,
@@ -344,7 +346,8 @@ void fasttrap_pid_probe_arch(fasttrap_probe_t *ftp, struct pt_regs *regs)
344346
}
345347
}
346348

347-
void fasttrap_pid_retprobe_arch(fasttrap_probe_t *ftp, struct pt_regs *regs)
349+
void fasttrap_pid_retprobe_arch(struct fasttrap_probe *ftp,
350+
struct pt_regs *regs)
348351
{
349352
/*
350353
* FIXME: The first argument to the probe should be the offset in the

arch/x86/dtrace/sdt_x86_64.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
static uint8_t sdt_invop(struct pt_regs *regs)
3131
{
32-
sdt_probe_t *sdt = sdt_probetab[SDT_ADDR2NDX(regs->ip)];
32+
struct sdt_probe *sdt = sdt_probetab[SDT_ADDR2NDX(regs->ip)];
3333

3434
for (; sdt != NULL; sdt = sdt->sdp_hashnext) {
3535
if ((uintptr_t)sdt->sdp_patchpoint == regs->ip) {
@@ -55,7 +55,7 @@ static uint8_t sdt_invop(struct pt_regs *regs)
5555
return 0;
5656
}
5757

58-
void sdt_provide_probe_arch(sdt_probe_t *sdp, struct module *mp, int idx)
58+
void sdt_provide_probe_arch(struct sdt_probe *sdp, struct module *mp, int idx)
5959
{
6060
sdp->sdp_patchval = SDT_PATCHVAL;
6161
sdp->sdp_savedval = *sdp->sdp_patchpoint;
@@ -70,12 +70,12 @@ void sdt_destroy_module(void *arg, struct module *mp)
7070
{
7171
}
7272

73-
void sdt_enable_arch(sdt_probe_t *sdp, dtrace_id_t id, void *arg)
73+
void sdt_enable_arch(struct sdt_probe *sdp, dtrace_id_t id, void *arg)
7474
{
7575
dtrace_invop_enable(sdp->sdp_patchpoint, sdp->sdp_patchval);
7676
}
7777

78-
void sdt_disable_arch(sdt_probe_t *sdp, dtrace_id_t id, void *arg)
78+
void sdt_disable_arch(struct sdt_probe *sdp, dtrace_id_t id, void *arg)
7979
{
8080
dtrace_invop_disable(sdp->sdp_patchpoint, sdp->sdp_savedval);
8181
}

arch/x86/include/asm/dtrace_arch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ typedef int (*prov_exit_f)(void);
2424
* - sdt_probec: number of SDT probes in the module
2525
* - pdata: pointer to a dtrace_module struct (for DTrace)
2626
*/
27-
typedef struct dtrace_module {
27+
struct dtrace_module {
2828
int enabled_cnt;
2929
size_t sdt_probe_cnt;
3030
size_t fbt_probe_cnt;
3131
prov_exit_f prov_exit; /* Called with module_mutex held */
32-
} dtrace_module_t;
32+
};
3333

3434
#endif /* _X86_DTRACE_ARCH_H */

arch/x86/kernel/dtrace_fbt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void dtrace_fbt_init(fbt_add_probe_fn fbt_add_probe, struct module *mp,
4747
loff_t pos;
4848
struct kallsym_iter sym;
4949
asm_instr_t *paddr = NULL;
50-
dt_fbt_bl_entry_t *blent = NULL;
50+
struct dt_fbt_bl_entry *blent = NULL;
5151

5252
/*
5353
* Look up any unresolved symbols in the blacklist, and sort the list

arch/x86/kernel/dtrace_syscall.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ asmlinkage long systrace_syscall(const struct pt_regs *regs);
3434
asmlinkage long dtrace_stub_ptregs(uintptr_t, uintptr_t, uintptr_t, uintptr_t,
3535
uintptr_t, uintptr_t, uintptr_t);
3636

37-
static systrace_info_t systrace_info =
37+
static struct systrace_info systrace_info =
3838
{
3939
&systrace_probe,
4040
systrace_stub,
@@ -53,7 +53,7 @@ asmlinkage long systrace_syscall(const struct pt_regs *regs)
5353
long rc = 0;
5454
unsigned long sysnum;
5555
dtrace_id_t id;
56-
dtrace_syscalls_t *sc;
56+
struct dtrace_syscalls *sc;
5757

5858
sysnum = syscall_get_nr(current, (struct pt_regs *) regs);
5959
sc = &systrace_info.sysent[sysnum];
@@ -81,7 +81,8 @@ asmlinkage long systrace_syscall(const struct pt_regs *regs)
8181
return rc;
8282
}
8383

84-
systrace_info_t *dtrace_syscalls_init(void)
84+
struct systrace_info *
85+
dtrace_syscalls_init(void)
8586
{
8687
int i;
8788

arch/x86/kernel/dtrace_util.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ void dtrace_handle_badaddr(struct pt_regs *regs)
6161
dtrace_skip_instruction(regs);
6262
}
6363

64-
typedef struct dtrace_invop_hdlr {
64+
struct dtrace_invop_hdlr {
6565
uint8_t (*dtih_func)(struct pt_regs *);
6666
struct dtrace_invop_hdlr *dtih_next;
67-
} dtrace_invop_hdlr_t;
67+
};
6868

69-
static dtrace_invop_hdlr_t *dtrace_invop_hdlrs;
69+
static struct dtrace_invop_hdlr *dtrace_invop_hdlrs;
7070

7171
/*
7272
* Trap notification handler.
@@ -128,8 +128,8 @@ int dtrace_die_notifier(struct notifier_block *nb, unsigned long val,
128128
dargs->trapnr = 6;
129129
}
130130
case DIE_TRAP: {
131-
dtrace_invop_hdlr_t *hdlr;
132-
int rval = 0;
131+
struct dtrace_invop_hdlr *hdlr;
132+
int rval = 0;
133133

134134
if (dargs->trapnr != 6)
135135
return NOTIFY_DONE;
@@ -175,8 +175,8 @@ int dtrace_die_notifier(struct notifier_block *nb, unsigned long val,
175175
}
176176
}
177177
case DIE_INT3: {
178-
dtrace_invop_hdlr_t *hdlr;
179-
int rval = 0;
178+
struct dtrace_invop_hdlr *hdlr;
179+
int rval = 0;
180180

181181
/*
182182
* Let's assume that this is a DTrace probe firing, so we need
@@ -232,9 +232,9 @@ int dtrace_die_notifier(struct notifier_block *nb, unsigned long val,
232232
*/
233233
int dtrace_invop_add(uint8_t (*func)(struct pt_regs *))
234234
{
235-
dtrace_invop_hdlr_t *hdlr;
235+
struct dtrace_invop_hdlr *hdlr;
236236

237-
hdlr = kmalloc(sizeof(dtrace_invop_hdlr_t), GFP_KERNEL);
237+
hdlr = kmalloc(sizeof(struct dtrace_invop_hdlr), GFP_KERNEL);
238238
if (hdlr == NULL) {
239239
pr_warn("Failed to add invop handler: out of memory\n");
240240
return -ENOMEM;
@@ -253,7 +253,7 @@ EXPORT_SYMBOL(dtrace_invop_add);
253253
*/
254254
void dtrace_invop_remove(uint8_t (*func)(struct pt_regs *))
255255
{
256-
dtrace_invop_hdlr_t *hdlr = dtrace_invop_hdlrs, *prev = NULL;
256+
struct dtrace_invop_hdlr *hdlr = dtrace_invop_hdlrs, *prev = NULL;
257257

258258
for (;;) {
259259
if (hdlr == NULL)
@@ -389,7 +389,7 @@ static int dtrace_user_addr_is_exec(uintptr_t addr)
389389
return ret;
390390
}
391391

392-
void dtrace_user_stacktrace(stacktrace_state_t *st)
392+
void dtrace_user_stacktrace(struct stacktrace_state *st)
393393
{
394394
struct pt_regs *regs = current_pt_regs();
395395
uint64_t *pcs = st->pcs;
@@ -441,10 +441,10 @@ void dtrace_user_stacktrace(stacktrace_state_t *st)
441441
}
442442
}
443443

444-
void dtrace_mod_pdata_init(dtrace_module_t *pdata)
444+
void dtrace_mod_pdata_init(struct dtrace_module *pdata)
445445
{
446446
}
447447

448-
void dtrace_mod_pdata_cleanup(dtrace_module_t *pdata)
448+
void dtrace_mod_pdata_cleanup(struct dtrace_module *pdata)
449449
{
450450
}

dtrace/dt_test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef _DT_TEST_H_
1818
#define _DT_TEST_H_
1919

20-
extern void dt_test_provide(void *, const dtrace_probedesc_t *);
20+
extern void dt_test_provide(void *, const struct dtrace_probedesc *);
2121
extern int dt_test_enable(void *arg, dtrace_id_t, void *);
2222
extern void dt_test_disable(void *arg, dtrace_id_t, void *);
2323
extern void dt_test_destroy(void *, dtrace_id_t, void *);

dtrace/dt_test_dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static struct dt_test_like_a_scatterlist
6767
{ .a = 6, .b = 7,
6868
.c = 8, .d = 9, .e = 10 } };
6969

70-
void dt_test_provide(void *arg, const dtrace_probedesc_t *desc)
70+
void dt_test_provide(void *arg, const struct dtrace_probedesc *desc)
7171
{
7272
dtrace_id_t probe;
7373

0 commit comments

Comments
 (0)