1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[misc] fix multiple VS Code Analysis warnings

This commit is contained in:
Pete Batard 2017-03-10 19:07:48 +01:00
parent 97b4e623cd
commit edcfd43ed5
13 changed files with 48 additions and 23 deletions

View file

@ -2,7 +2,7 @@
* Rufus: The Reliable USB Formatting Utility
* Formatting function calls
* Copyright © 2007-2009 Tom Thornhill/Ridgecrop
* Copyright © 2011-2016 Pete Batard <pete@akeo.ie>
* Copyright © 2011-2017 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -865,6 +865,9 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
AnalyzeMBR(hPhysicalDrive, "Drive");
if (SelectedDrive.SectorSize < 512)
goto out;
// FormatEx rewrites the MBR and removes the LBA attribute of FAT16
// and FAT32 partitions - we need to correct this in the MBR
buffer = (unsigned char*)_mm_malloc(SelectedDrive.SectorSize, 16);

View file

@ -45,6 +45,7 @@
#include <cdio/util.h>
#include "_cdio_stream.h"
#include "_cdio_stdio.h"
#include "cdio_assert.h"
/* On 32 bit platforms, fseek can only access streams of 2 GB or less.
Prefer fseeko/fseeko64, that take a 64 bit offset when LFS is enabled */
@ -265,6 +266,7 @@ cdio_stdio_new(const char pathname[])
}
ud = calloc (1, sizeof (_UserData));
cdio_assert (ud != NULL);
ud->pathname = pathdup;
ud->st_size = statbuf.st_size; /* let's hope it doesn't change... */

View file

@ -99,6 +99,7 @@ cdio_stream_new(void *user_data, const cdio_stream_io_functions *funcs)
CdioDataSource_t *new_obj;
new_obj = calloc (1, sizeof (CdioDataSource_t));
cdio_assert (new_obj != NULL);
new_obj->user_data = user_data;
memcpy(&(new_obj->op), funcs, sizeof(cdio_stream_io_functions));

View file

@ -85,6 +85,7 @@ _cdio_list_prepend (CdioList_t *p_list, void *p_data)
cdio_assert (p_list != NULL);
p_new_node = calloc (1, sizeof (CdioListNode_t));
cdio_assert (p_new_node != NULL);
p_new_node->list = p_list;
p_new_node->next = p_list->begin;
@ -109,6 +110,7 @@ _cdio_list_append (CdioList_t *p_list, void *p_data)
else
{
CdioListNode_t *p_new_node = calloc (1, sizeof (CdioListNode_t));
cdio_assert (p_new_node != NULL);
p_new_node->list = p_list;
p_new_node->next = NULL;

View file

@ -42,6 +42,7 @@
#include <cdio/utf8.h>
#include <cdio/logging.h>
#include <cdio/memory.h>
#include "cdio_assert.h"
/* Windows requires some basic UTF-8 support outside of Joliet */
#if defined(_WIN32)
@ -300,6 +301,7 @@ bool cdio_charset_from_utf8(cdio_utf8_t * src, char ** dst,
/* Perform byte reversal */
len = wcslen(le_dst);
*dst = (char*)calloc(len+1, sizeof(wchar_t));
cdio_assert(*dst != NULL);
for (i=0; i<2*len; i++) {
(*dst)[i] = ((char*)le_dst)[i+1];
(*dst)[i+1] = ((char*)le_dst)[i];
@ -333,6 +335,7 @@ bool cdio_charset_to_utf8(const char *src, size_t src_len, cdio_utf8_t **dst,
/* Perform byte reversal */
le_src = (wchar_t*)malloc(2*src_len+2);
cdio_assert(le_src != NULL);
for (i=0; i<src_len; i++) {
((char*)le_src)[2*i] = src[2*i+1];
((char*)le_src)[2*i+1] = src[2*i];

View file

@ -62,7 +62,7 @@ void
_cdio_strfreev(char **strv)
{
int n;
cdio_assert (strv != NULL);
for(n = 0; strv[n]; n++)
@ -88,14 +88,15 @@ _cdio_strsplit(const char str[], char delim) /* fixme -- non-reentrant */
n = 1;
p = _str;
while(*p)
while(*p)
if (*(p++) == delim)
n++;
strv = calloc (1, sizeof (char *) * (n+1));
strv = calloc (n+1, sizeof (char *));
cdio_assert (strv != NULL);
n = 0;
while((p = strtok(n ? NULL : _str, _delim)) != NULL)
while((p = strtok(n ? NULL : _str, _delim)) != NULL)
strv[n++] = strdup(p);
free(_str);
@ -111,9 +112,10 @@ _cdio_memdup (const void *mem, size_t count)
if (mem)
{
new_mem = calloc (1, count);
cdio_assert (new_mem != NULL);
memcpy (new_mem, mem, count);
}
return new_mem;
}
@ -141,7 +143,7 @@ _cdio_strdup_upper (const char str[])
/* Convert MinGW/MSYS paths that start in "/c/..." to "c:/..."
so that they can be used with fopen(), stat(), etc.
Returned string must be freed by the caller using cdio_free().*/
char *
char *
_cdio_strdup_fixpath (const char path[])
{
char *new_path = NULL;
@ -180,7 +182,7 @@ const char *cdio_version_string = CDIO_VERSION;
const unsigned int libcdio_version_num = LIBCDIO_VERSION_NUM;
/*
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8

View file

@ -960,8 +960,10 @@ _fs_stat_traverse (const CdIo_t *p_cdio, const iso9660_stat_t *_root,
{
unsigned int len=sizeof(iso9660_stat_t) + strlen(_root->filename)+1;
p_stat = calloc(1, len);
cdio_assert (p_stat != NULL);
memcpy(p_stat, _root, len);
p_stat->rr.psz_symlink = calloc(1, p_stat->rr.i_symlink_max);
cdio_assert (p_stat->rr.psz_symlink != NULL);
memcpy(p_stat->rr.psz_symlink, _root->rr.psz_symlink,
p_stat->rr.i_symlink_max);
return p_stat;
@ -1055,13 +1057,10 @@ _fs_iso_stat_traverse (iso9660_t *p_iso, const iso9660_stat_t *_root,
iso9660_stat_t *p_stat;
unsigned int len=sizeof(iso9660_stat_t) + strlen(_root->filename)+1;
p_stat = calloc(1, len);
if (!p_stat)
{
cdio_warn("Couldn't calloc(1, %d)", len);
return NULL;
}
cdio_assert (p_stat != NULL);
memcpy(p_stat, _root, len);
p_stat->rr.psz_symlink = calloc(1, p_stat->rr.i_symlink_max);
cdio_assert (p_stat->rr.psz_symlink != NULL);
memcpy(p_stat->rr.psz_symlink, _root->rr.psz_symlink,
p_stat->rr.i_symlink_max);
return p_stat;

View file

@ -254,8 +254,8 @@ udf_fopen(udf_dirent_t *p_udf_root, const char *psz_name)
/* file position must be reset when accessing a new file */
p_udf_root->p_udf->i_position = 0;
tokenline[udf_MAX_PATHLEN-1] = '\0';
strncpy(tokenline, psz_name, udf_MAX_PATHLEN-1);
tokenline[udf_MAX_PATHLEN-1] = '\0';
psz_token = strtok(tokenline, udf_PATH_DELIMITERS);
if (psz_token) {
udf_dirent_t *p_udf_dirent =

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Elementary Unicode compliant find/replace parser
* Copyright © 2012-2016 Pete Batard <pete@akeo.ie>
* Copyright © 2012-2017 Pete Batard <pete@akeo.ie>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1234,7 +1234,7 @@ out:
}
/*
* Replace all 'c' characters in string 'src' with the subtsring 'rep'
* Replace all 'c' characters in string 'src' with the substring 'rep'
* The returned string is allocated and must be freed by the caller.
*/
char* replace_char(const char* src, const char c, const char* rep)
@ -1256,6 +1256,10 @@ char* replace_char(const char* src, const char c, const char* rep)
for(k=0; k<rep_len; k++)
res[j++] = rep[k];
} else {
// Since the VS Code Analysis tool is dumb...
#if defined(_MSC_VER)
#pragma warning(suppress: 6386)
#endif
res[j++] = src[i];
}
}

View file

@ -20,7 +20,7 @@
#include <inttypes.h>
#if defined(_MSC_VER)
// Disable some VS2012 Code Analysis warnings
// Disable some VS Code Analysis warnings
#pragma warning(disable: 4996) // Ignore deprecated (eg. GetVersionEx()), as we have to contend with XP
#pragma warning(disable: 28159) // We use GetTickCount64() where possible, but it's not available on XP
#pragma warning(disable: 6258) // I know what I'm using TerminateThread for

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 2.13.1070"
CAPTION "Rufus 2.13.1071"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -334,8 +334,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,13,1070,0
PRODUCTVERSION 2,13,1070,0
FILEVERSION 2,13,1071,0
PRODUCTVERSION 2,13,1071,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -352,13 +352,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.13.1070"
VALUE "FileVersion", "2.13.1071"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.13.1070"
VALUE "ProductVersion", "2.13.1071"
END
END
BLOCK "VarFileInfo"

View file

@ -373,7 +373,14 @@ char* FileDialog(BOOL save, char* path, const ext_t* ext, DWORD options)
j = _snprintf(&ext_string[j], ext_strlen-j, "%s (*.*)\r*.*\r", all_files);
// Microsoft could really have picked a better delimiter!
for (i=0; i<ext_strlen; i++) {
// Since the VS Code Analysis tool is dumb...
#if defined(_MSC_VER)
#pragma warning(suppress: 6385)
#endif
if (ext_string[i] == '\r') {
#if defined(_MSC_VER)
#pragma warning(suppress: 6386)
#endif
ext_string[i] = 0;
}
}

View file

@ -151,6 +151,8 @@ DWORD M_NTFSSECT_API NtfsSectGetVolumeInfo(
rc = NtfsSectGetVolumeHandle(VolumeName, VolumeInfo);
if (rc != ERROR_SUCCESS)
goto err_handle;
if ((VolumeInfo->Handle == NULL) || (VolumeInfo->Handle == INVALID_HANDLE_VALUE))
return ERROR_INVALID_HANDLE;
}
rc = NtfsSectLoadXpFuncs(&xp_funcs);