Skip to content

Commit

Permalink
Fix a number of CodeQL warnings (#14882)
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink authored Jan 4, 2024
1 parent 54f8212 commit 7e1afc3
Show file tree
Hide file tree
Showing 24 changed files with 133 additions and 156 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/codeql_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.5

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand All @@ -41,11 +46,6 @@ jobs:
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.5

- name: Get base dependencies
run: |
sudo DEBIAN_FRONTEND="noninteractive" apt-get update
Expand Down
8 changes: 4 additions & 4 deletions go/cmd/vtctldclient/command/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ If no replica-type tablet can be found, the backup can be taken on the primary i

var backupOptions = struct {
AllowPrimary bool
Concurrency uint64
Concurrency int32
IncrementalFromPos string
UpgradeSafe bool
}{}
Expand Down Expand Up @@ -119,7 +119,7 @@ func commandBackup(cmd *cobra.Command, args []string) error {

var backupShardOptions = struct {
AllowPrimary bool
Concurrency uint64
Concurrency int32
IncrementalFromPos string
UpgradeSafe bool
}{}
Expand Down Expand Up @@ -280,14 +280,14 @@ func commandRestoreFromBackup(cmd *cobra.Command, args []string) error {

func init() {
Backup.Flags().BoolVar(&backupOptions.AllowPrimary, "allow-primary", false, "Allow the primary of a shard to be used for the backup. WARNING: If using the builtin backup engine, this will shutdown mysqld on the primary and stop writes for the duration of the backup.")
Backup.Flags().Uint64Var(&backupOptions.Concurrency, "concurrency", 4, "Specifies the number of compression/checksum jobs to run simultaneously.")
Backup.Flags().Int32Var(&backupOptions.Concurrency, "concurrency", 4, "Specifies the number of compression/checksum jobs to run simultaneously.")
Backup.Flags().StringVar(&backupOptions.IncrementalFromPos, "incremental-from-pos", "", "Position of previous backup. Default: empty. If given, then this backup becomes an incremental backup from given position. If value is 'auto', backup taken from last successful backup position")

Backup.Flags().BoolVar(&backupOptions.UpgradeSafe, "upgrade-safe", false, "Whether to use innodb_fast_shutdown=0 for the backup so it is safe to use for MySQL upgrades.")
Root.AddCommand(Backup)

BackupShard.Flags().BoolVar(&backupShardOptions.AllowPrimary, "allow-primary", false, "Allow the primary of a shard to be used for the backup. WARNING: If using the builtin backup engine, this will shutdown mysqld on the primary and stop writes for the duration of the backup.")
BackupShard.Flags().Uint64Var(&backupShardOptions.Concurrency, "concurrency", 4, "Specifies the number of compression/checksum jobs to run simultaneously.")
BackupShard.Flags().Int32Var(&backupShardOptions.Concurrency, "concurrency", 4, "Specifies the number of compression/checksum jobs to run simultaneously.")
BackupShard.Flags().StringVar(&backupShardOptions.IncrementalFromPos, "incremental-from-pos", "", "Position of previous backup. Default: empty. If given, then this backup becomes an incremental backup from given position. If value is 'auto', backup taken from last successful backup position")
BackupShard.Flags().BoolVar(&backupOptions.UpgradeSafe, "upgrade-safe", false, "Whether to use innodb_fast_shutdown=0 for the backup so it is safe to use for MySQL upgrades.")
Root.AddCommand(BackupShard)
Expand Down
8 changes: 4 additions & 4 deletions go/cmd/vtctldclient/command/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func commandReloadSchema(cmd *cobra.Command, args []string) error {
}

var reloadSchemaKeyspaceOptions = struct {
Concurrency uint32
Concurrency int32
IncludePrimary bool
}{
Concurrency: 10,
Expand All @@ -254,7 +254,7 @@ func commandReloadSchemaKeyspace(cmd *cobra.Command, args []string) error {
}

var reloadSchemaShardOptions = struct {
Concurrency uint32
Concurrency int32
IncludePrimary bool
}{
Concurrency: 10,
Expand Down Expand Up @@ -307,11 +307,11 @@ func init() {

Root.AddCommand(ReloadSchema)

ReloadSchemaKeyspace.Flags().Uint32Var(&reloadSchemaKeyspaceOptions.Concurrency, "concurrency", 10, "Number of tablets to reload in parallel. Set to zero for unbounded concurrency.")
ReloadSchemaKeyspace.Flags().Int32Var(&reloadSchemaKeyspaceOptions.Concurrency, "concurrency", 10, "Number of tablets to reload in parallel. Set to zero for unbounded concurrency.")
ReloadSchemaKeyspace.Flags().BoolVar(&reloadSchemaKeyspaceOptions.IncludePrimary, "include-primary", false, "Also reload the primary tablets.")
Root.AddCommand(ReloadSchemaKeyspace)

ReloadSchemaShard.Flags().Uint32Var(&reloadSchemaShardOptions.Concurrency, "concurrency", 10, "Number of tablets to reload in parallel. Set to zero for unbounded concurrency.")
ReloadSchemaShard.Flags().Int32Var(&reloadSchemaShardOptions.Concurrency, "concurrency", 10, "Number of tablets to reload in parallel. Set to zero for unbounded concurrency.")
ReloadSchemaShard.Flags().BoolVar(&reloadSchemaShardOptions.IncludePrimary, "include-primary", false, "Also reload the primary tablet.")
Root.AddCommand(ReloadSchemaShard)
}
2 changes: 1 addition & 1 deletion go/cmd/vtctldclient/command/shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ func commandSourceShardDelete(cmd *cobra.Command, args []string) error {
return err
}

uid, err := strconv.ParseUint(cmd.Flags().Arg(1), 10, 32)
uid, err := strconv.ParseInt(cmd.Flags().Arg(1), 10, 32)
if err != nil {
return fmt.Errorf("Failed to parse SourceShard uid: %w", err) // nolint
}
Expand Down
6 changes: 3 additions & 3 deletions go/vt/proto/tabletmanagerdata/tabletmanagerdata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions go/vt/proto/vtadmin/vtadmin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/vt/proto/vtadmin/vtadmin_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions go/vt/proto/vtctldata/vtctldata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions go/vt/proto/vtctldata/vtctldata_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7e1afc3

Please sign in to comment.