Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdae00f3

Browse files
committed
aio: Improve assertions related to io_method
First, the assertions in assign_io_method() were the wrong way round. Second,the lengthof() assertion checked the length of io_method_options, which is thewrong array to check and is always longer than pgaio_method_ops_table.While add it, add a static assert to ensure pgaio_method_ops_table andio_method_options stay in sync.Per coverity and Tom Lane.Reported-by: Tom Lane <tgl@sss.pgh.pa.us>Backpatch-through: 18
1 parent2d83d72 commitdae00f3

File tree

1 file changed

+4
-1
lines changed
  • src/backend/storage/aio

1 file changed

+4
-1
lines changed

‎src/backend/storage/aio/aio.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ static const IoMethodOps *const pgaio_method_ops_table[] = {
8989
#endif
9090
};
9191

92+
StaticAssertDecl(lengthof(io_method_options)==lengthof(pgaio_method_ops_table)+1,
93+
"io_method_options out of sync with pgaio_method_ops_table");
94+
9295
/* callbacks for the configured io_method, set by assign_io_method */
9396
constIoMethodOps*pgaio_method_ops;
9497

@@ -1318,8 +1321,8 @@ pgaio_shutdown(int code, Datum arg)
13181321
void
13191322
assign_io_method(intnewval,void*extra)
13201323
{
1324+
Assert(newval<lengthof(pgaio_method_ops_table));
13211325
Assert(pgaio_method_ops_table[newval]!=NULL);
1322-
Assert(newval<lengthof(io_method_options));
13231326

13241327
pgaio_method_ops=pgaio_method_ops_table[newval];
13251328
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp